xoops forums

dantom

Friend of XOOPS
Posted on: 2004/4/6 0:40
dantom
dantom (Show more)
Friend of XOOPS
Posts: 20
Since: 2003/6/21
#1

form->insertBreak() doesn't work? Where do i wrong?

Hello! I am am (hope! ) e xoops-programmers. What's mean?
That i love to built my xoops's page using an xoops' object
It is very natrally for me. But there is a little problem that i don't understand
when i am using a xoopsForm Object. I explain:

I want insert a row in xoops-form between two element and I have a problem with a
insertBreak(); method in XoopsThemeForm.php class

Here is the brief code for example:

============================================================
include XOOPS_ROOT_PATH."/class/xoopsformloader.php";

$form = new XoopsThemeForm('Aggiungi Xoopsit User', 'addUser', 'adduser.php', 'POST');

//add a textbox for insert username ->OK!
$form->addElement(new XoopsFormText('Nick:', 'user'));

//I try to insert a html row (there are three mode i think...if i understand ):
____________________________________

$form->insertBreak(); // just an empty row doesn't work
$form->insertBreak('<b>Some html or text</b>'); //doesn't work or or like this...
$form->insertBreak('<b>Some Some html or text','someCSSclass'); // doesn't work

am i e very dummy xoopser Where is the wrong?
______________________________________

//buttom for submit and reset ->OK!
$submit = new XoopsFormButton('', 'submit','Invia');
$reset = new XoopsFormButton('', 'reset','Reset', 'reset');
$button_tray = new XoopsFormElementTray("", "&nbsp;");
$button_tray->addElement($submit);
$button_tray->addElement($reset);
$form->addElement($button_tray);

//display form...->OK!
$form->display();
======================================================================================

I can see a text for username and the submit and reset button BUT...

insertBreak is dead...:-|

Do you know where i wrong?

thank you

dan_mtv

fatman

Friend of XOOPS
Posted on: 2004/4/6 1:24
fatman
fatman (Show more)
Friend of XOOPS
Posts: 176
Since: 2003/12/13
#2

Re: form->insertBreak() doesn't work? Where do i wrong?

You could try using the XoopsFormLabel element. This is works just like adding any element to your form, only the label one doesn't add an actual field, just lets you add an extra label or a small blob of text.

$form->addElement(new XoopsFormLabel('My Caption', '<b>Some html or text</b>'));

dantom

Friend of XOOPS
Posted on: 2004/4/6 2:26
dantom
dantom (Show more)
Friend of XOOPS
Posts: 20
Since: 2003/6/21
#3

Re: form->insertBreak() doesn't work? Where do i wrong?

Thank for you answer....
I know...eheheh that is an another way

But i would you like to say...

why doesn't work insertBreak();?

dan_mtv

DaBoyz

Just popping in
Posted on: 2004/4/6 7:56
DaBoyz
DaBoyz (Show more)
Just popping in
Posts: 79
Since: 2002/8/8 1
#4

Re: form->insertBreak() doesn't work? Where do i wrong?

Quote:
why doesn't work insertBreak();?


Did you try "Search" ?

You could have a link to this or this ...

Dave_L

XOOPS is my life!
Posted on: 2004/4/6 10:24
Dave_L
Dave_L (Show more)
XOOPS is my life!
Posts: 2277
Since: 2003/11/7
#5

Re: form->insertBreak() doesn't work? Where do i wrong?

Those links are from last October.

Posted as bug in tracker.

Mithrandir

XOOPS is my life!
Posted on: 2004/4/6 11:01
Mithrandir
Mithrandir (Show more)
XOOPS is my life!
Posts: 6320
Since: 2003/6/21
#6

Re: form->insertBreak() doesn't work? Where do i wrong?

I've made a little XoopsElement child class for making this linebreak:

class XoopsFormLinebreak extends XoopsFormElement {

    
/**
     * Value
     * @var    string    
     * @access    private
     */
    
var $_value;

    
/**
     * Constructor
     * 
     */
    
function XoopsFormLinebreak($caption ""){
        
$this->setCaption($caption);
    }

    
/**
     * Prepare HTML for output
     * 
     * @return    string    HTML
     */
    
function render(){
        return 
"&nbsp;";
    }
}

Added like a normal form element with the option of having a caption value.

Could probably be improved.

Edit: Improved to take class from themeform

dantom

Friend of XOOPS
Posted on: 2004/4/6 22:51
dantom
dantom (Show more)
Friend of XOOPS
Posts: 20
Since: 2003/6/21
#7

Re: form->insertBreak() doesn't work? Where do i wrong?

Thank to Dave_L, DaBoyz, fatman

I try like this:
1 - I create a class file XoopsFormLinebreak.php and put it in root/class/xoopsform with a code of Mithrandir (thank )

2 - After i use it like this

$breakLine = new XoopsFormLinebreak();
$form->addElement($breakLine); //Is it right?

return blank page

==================================

I try to read info-bug by - Dave Lerner - dave_l -

Maybe XoopsThemeForm::insertBreak() needs to
instantiate a XoopsFormLabel, and pass that instead of
a string.

And i try like this:
$form->insertBreak(new XoopsFormLabel('&nbsp;', '&nbsp;'), 'odd'); //doesn't work

Until now, i can built a line break ina tableform only
like this:
$form->addElement(new XoopsFormLabel('&nbsp;', '&nbsp;')); //WORK!!!

But i want use insertBreak!
i am using a XOOPS 2.0.6

I must forget insertBreak();?

Mithrandir

XOOPS is my life!
Posted on: 2004/4/6 23:02
Mithrandir
Mithrandir (Show more)
XOOPS is my life!
Posts: 6320
Since: 2003/6/21
#8

Re: form->insertBreak() doesn't work? Where do i wrong?

insertBreak has a basic flaw in thinking that it can make a string and use the addElement() method to add it - which you cannot.

If the ->addElement(new XoopsFormLabel('&nbsp;', '&nbsp;')) works (which I have no doubt it does and should) then use that.

However, it annoys me a bit that the XoopsFormLineBreak() ain't working. Could you turn on php debug and see what it shows? Basically, it does just what an empty XoopsFormLabel would do, though.

dantom

Friend of XOOPS
Posted on: 2004/4/6 23:21
dantom
dantom (Show more)
Friend of XOOPS
Posts: 20
Since: 2003/6/21
#9

Re: form->insertBreak() doesn't work? Where do i wrong?


WOW!!!!!

$form->addElement(new XoopsFormLinebreak()); // WORKS

I use always PHP debug. it Is very important in this case. but in THIS case i forget to use it.

So..

I activeted php debug and return something similiar "class don't exist!!

I forget to include a link in xoopsformloader.php

GREAT! THANK YOU!

Brad

Not too shy to talk
Posted on: 2004/4/7 2:28
Brad
Brad (Show more)
Not too shy to talk
Posts: 150
Since: 2003/12/4
#10

Re: form->insertBreak() doesn't work? Where do i wrong?

I have also made my own class for adding a break into a form. Mine is specific to the xoopsThemeForm (or whichever one that is). Not sure if it'd work in the other form classes.

class XoopsFormBreak extends XoopsFormElement {

    
/**
     * Constructor
     * 
     * @param    string    $caption    Caption
     * @param    string    $class        Text
     */
    
function XoopsFormBreak($caption ''$class''){

        if (!empty(
$class)) {
            
$class "class='$class'";
        }

        
$this->setClass($class);
        
$this->setCaption($caption);
        
$this->setHidden();
    }

    
/**
     * Prepare HTML for output
     * 
     * @return    string
     */
    
function render(){
        return 
"<tr><td colspan='2' " $this->getClass() . "/>"$this->getCaption() . "</td></tr>";
    }
}