1
mawi27
Howto integrate a form
  • 2006/2/5 16:03

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


Hi all,

i have a question about integrating a form into a custom module.
With:
Quote:

$testform = new XoopsSimpleForm('Testform', 'name of form', 'index.php', 'POST');
$testform->addElement(new XoopsFormText("testform", "testformdata", 25, 10, "default"));
$testform->display();

i can show a textbox on the page.
But i can't find any hint how to get the data out of the textbox.
What is the varname, and how do i get it after writing into that Box?

Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

2
3lr0n
Re: Howto integrate a form
  • 2006/2/5 19:04

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


You have to access this data in the variable $_POST['testformdata']

For example look at this code on changepass.php from profile module:

$xoopsUser->setVar('pass'md5($_POST['newpass']));
Spanish Overclocking Community xoops based site : http://www.overclocking.es

3
mawi27
Re: Howto integrate a form
  • 2006/2/6 4:37

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


Thanks 3Ir0n,

changepass.php is a good example for this.

Does somebody have another good tip for me on how to use the XoopsFormSelect Element?

I tried
Quote:

$optionsTitles[] = "Testtitle1";
$optionsTitles[] = "Testtitle2";
$optionsTitles[] = "Testtitle3";
$frmSelTitle = new XoopsThemeForm('Select', 'SelTitle', 'index.php', 'POST');
$frmSelTitle->addElement(new XoopsFormSelect($caption="Select Title", $name="selTitle", $value=null, $size=1, $multiple=false));
$frmSelTitle->addOptionArray($optionsTitles);
$frmSelTitle->display();


but i only get the following error message:
Fatal error: Call to undefined method XoopsThemeForm::addOptionArray() in ...

i also tried to the same result
Quote:

$optionsTitles = array("1" => "Testtitle1",
"2" => "Testtitle2",
"3" => "Testtitle3")


I don't get it, cause i saw many examples 'quite' similar

Xoops Version 2.2.4

Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

4
Dave_L
Re: Howto integrate a form
  • 2006/2/6 4:45

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


addOptionArray is a method of the form element, not of the form.

$optionsTitles = array(
   
'1' => 'Testtitle1',
   
'2' => 'Testtitle2',
   
'3' => 'Testtitle3',
);

$form = new XoopsThemeForm('Select''SelTitle''index.php''post'true);
$menu = new XoopsFormSelect('Select Title''selTitle'null1false);
$menu->addOptionArray($optionsTitles);
$form->addElement($menu);
$form->display();

5
mawi27
Re: Howto integrate a form
  • 2006/2/6 4:59

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


I changed names a bit, because there where some doubles.
Now using:
$options = array("1" => "Testtitle1""2" => "Testtitle2""3" => "Testtitle3");

/*
$options[] = "Testtitle1";
$options[] = "Testtitle2";
$options[] = "Testtitle3";
*/                                         
print_r($options);
$formSelect =  new XoopsThemeForm('Select''SelectForm''index.php''POST');
$frmSelTitle->addElement(new XoopsFormSelect($caption="Select Title"$name="selectTitle"$value=null$size=1$multiple=false));
$frmSelTitle->addOptionArray($options);
$formSelect->display();


same error:
Array ( [1] => Testtitle1 [2] => Testtitle2 [3] => Testtitle3 )
Fatal error: Call to a member function addElement() on a non-object in ...


Marco

Edit: not quite the same error, as i see now.
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

6
mawi27
Re: Howto integrate a form
  • 2006/2/6 5:07

  • mawi27

  • Friend of XOOPS

  • Posts: 103

  • Since: 2006/1/1 1


Hi Dave_L,

i have changed the code according to your example and now it works.
1st have to add the options to the select box and afterwards add the select box to the form.


Thanks alot,

Marco
--
Match Dart!
Darts Ranking, News, Videos, Forum and more

Login

Who's Online

358 user(s) are online (116 user(s) are browsing Support Forums)


Members: 0


Guests: 358


more...

Donat-O-Meter

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

Latest GitHub Commits