1
dantom
form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 0:40

  • dantom

  • Friend of XOOPS

  • Posts: 20

  • Since: 2003/6/21


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('Some html or text'); //doesn't work or or like this...
$form->insertBreak('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("", " ");
$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

2
fatman
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 1:24

  • fatman

  • Friend of XOOPS

  • Posts: 176

  • Since: 2003/12/13


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', 'Some html or text'));

3
dantom
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 2:26

  • dantom

  • Friend of XOOPS

  • Posts: 20

  • Since: 2003/6/21


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

4
DaBoyz
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 7:56

  • DaBoyz

  • Just popping in

  • Posts: 79

  • Since: 2002/8/8 1


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


Did you try "Search" ?

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

5
Dave_L
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 10:24

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Those links are from last October.

Posted as bug in tracker.

6
Mithrandir
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 
" ";
    }
}

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

7
dantom
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 22:51

  • dantom

  • Friend of XOOPS

  • Posts: 20

  • Since: 2003/6/21


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(' ', ' '), 'odd'); //doesn't work

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

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

I must forget insertBreak();?

8
Mithrandir
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(' ', ' ')) 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.

9
dantom
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/6 23:21

  • dantom

  • Friend of XOOPS

  • Posts: 20

  • Since: 2003/6/21



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!


10
Brad
Re: form->insertBreak() doesn't work? Where do i wrong?
  • 2004/4/7 2:28

  • Brad

  • Not too shy to talk

  • Posts: 150

  • Since: 2003/12/4


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 
"$this->getClass() . "/>"$this->getCaption() . "";
    }
}

Login

Who's Online

391 user(s) are online (291 user(s) are browsing Support Forums)


Members: 0


Guests: 391


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits