1
xsell
XoopsFormHidden
  • 2010/1/1 5:11

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Hello

In my Code if i use
new XoopsFormHidden


for Somereason the Form dose not include the $id Value . but if i use
new XoopsFormText
it works and includes the ID value .. but i need it hidden .

after posting with new XoopsFormHidden
the resualt likehttp://localhost/xoops/modules/test/index.php?id=

but with new XoopsFormText , i get exactly wht i want
http://localhost/xoops/modules/test/index.php?id=1

this is the Code with new XoopsFormText which i do not want i want it to work with new XoopsFormHidden

$myts =& MyTextSanitizer::getInstance();
      
$id $myts->makeTboxData4Save($_POST["id"]);
      
 include_once 
XOOPS_ROOT_PATH."/class/xoopsformloader.php";

$xoopsTpl->assign('form1'$form = new XoopsThemeForm(_MI_SEND"form1""send.php"));
$xoopsTpl->assign('id'$the_id = new XoopsFormText(_MI_ID"id"''''$id));

$xoopsTpl->assign('id'$form->addElement($the_id));

$xoopsTpl->assign('send'$submit = new XoopsFormButton("""submit"_MI_SENDNOW"submit"));
$xoopsTpl->assign('send'$form->addElement($submit));
$form->display();

2
xsell
Re: XoopsFormHidden
  • 2010/1/2 0:20

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


up :)

3
Dylian
Re: XoopsFormHidden
  • 2010/1/5 1:05

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Don't really get what your trying to do, but this is the working version of the script you posted above.

(I removed the template vars as they ain't needed for proper functioning of the script)

Version 1:
<?php 

require('mainfile.php');
include(
$GLOBALS['xoops']->path('header.php'));

if(!empty(
$_GET["id"])){
    
$id intval($_GET["id"]);
}elseif(!empty(
$_POST["id"])){
    
$id intval($_POST["id"]);
}else{
    
// do something if no id is set
}

xoops_load('xoopsformloader');

$form = new XoopsThemeForm(_MI_SEND"form1""send.php"); 

$hidden_id = new XoopsFormHidden('id'$id);
$form->addElement($hidden_id);

$button_submit = new XoopsFormButton("""submit"_MI_SENDNOW"submit"); 
$form->addElement($button_submit); 

$form->display();


include(
$GLOBALS['xoops']->path('footer.php'));
?>


This version puts the form in the <{$form}> template var (If you realy wan't to work with templates )

Version 2:
<?php 

require('mainfile.php');
include(
$GLOBALS['xoops']->path('header.php'));

if(!empty(
$_GET["id"])){
    
$id intval($_GET["id"]);
}elseif(!empty(
$_POST["id"])){
    
$id intval($_POST["id"]);
}else{
    
// do something if no id is set
}

xoops_load('xoopsformloader');

$form = new XoopsThemeForm(_MI_SEND"form1""send.php"); 

$hidden_id = new XoopsFormHidden('id'$id);
$form->addElement($hidden_id);

$button_submit = new XoopsFormButton("""submit"_MI_SENDNOW"submit"); 
$form->addElement($button_submit); 

$xoopsTpl->assign('form'$form->display()); 


include(
$GLOBALS['xoops']->path('footer.php'));
?>


Hope this does what you want it to do and otherwise please try to explain what your trying to do...

Greets Dylian.

4
xsell
Re: XoopsFormHidden
  • 2010/1/5 3:25

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Thx Dylian ,

My way and your way Still Give the Same Result .

Ok this The Problem in Simple Words .

the $ID Value Should Be Replaced with the actual ID Number.

But For Some reason the $ID Value if i make the Form Hidden Stays Empty.

See the Image Explain to You Better.
Resized Image

5
Dylian
Re: XoopsFormHidden
  • 2010/1/5 10:25

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


If you look at the source code in your browser you'll see that the id field does have a value... (a html code lik this generated: <input type="hidden" name="id" value="1234" />

Or is this what you want?
1. user goes to id.php?id=123;
2. user fills in the visible fields;
3. user submits form and goes to send.php?id=123
4. send.php parses the data the user filled in.

If so, use this code:
<?php  

require('mainfile.php'); 
include(
$GLOBALS['xoops']->path('header.php')); 

if(!empty(
$_GET["id"])){ 
    
$id intval($_GET["id"]); 
}elseif(!empty(
$_POST["id"])){ 
    
$id intval($_POST["id"]); 
}else{ 
    
// do something if no id is set 


xoops_load('xoopsformloader'); 

// Added the id to the action url instead of putting it in a hidden field
$form = new XoopsThemeForm(_MI_SEND"form1""send.php?id=".$id);
//$hidden_id = new XoopsFormHidden('id', $id); 
//$form->addElement($hidden_id); 

$button_submit = new XoopsFormButton("""submit"_MI_SENDNOW"submit");  
$form->addElement($button_submit);  

$form->display(); // OR
//$xoopsTpl->assign('form', $form->display()); 


include($GLOBALS['xoops']->path('footer.php')); 
?>


Greets Dylian.

6
xsell
Re: XoopsFormHidden
  • 2010/1/5 19:23

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Dylian Thank you Man ,

I feel Very Stupid , How in the World I could Not think about that .. Your Total Correct . it Should Be .

$form = new XoopsThemeForm(_MI_SEND"form1""send.php?id=".$id);


Not

$form = new XoopsThemeForm(_MI_SEND"form1""send.php");


with That No need for Extra Hidden Filed , i can remove it Now ..

Shame On me , was very Simple if Paid Good attention to my Code ..

Thank you Dylian for Ponited it Out.

Login

Who's Online

180 user(s) are online (133 user(s) are browsing Support Forums)


Members: 0


Guests: 180


more...

Donat-O-Meter

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

Latest GitHub Commits