Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] How to capture form_hidden ?
#1

[eluser]solid9[/eluser]
I created a form_hidden

Code:
form_hidden('swap_id', $swap->id);

now I tried to catch it like this below,
Code:
$swap_id = $this->input->post('swap_id');

After that I echoed it,
Code:
echo 'ID:', $swap_id;

But nothing shows.

Why?

#2

[eluser]PhilTem[/eluser]
Try to do a

Code:
var_dump($this->input->post('swap_id');

to see, if it's not FALSE (which implies, that the post value isn't available).

On another point of view: Did you set your form's method to

Code:
method="POST"

otherwise (i.e. with method="GET") you won't be able to access it with input->post.

However, hidden fields are just not visible to the user but are valid input fields hence should be within your post-array.
#3

[eluser]solid9[/eluser]
Yes I tried the var_dump and I got this value below,
Code:
bool(false)


Regarding the method="POST" I believed that's already included
with the codes below,
Code:
echo form_open('main/process_post');

It's in the documentation,
http://ellislab.com/codeigniter/user-gui...elper.html

But then again, please correct me if I'm wrong.




#4

[eluser]InsiteFX[/eluser]
Code:
<?php
$swap = $swap->id;
form_hidden('swap_id', $swap);
?>
#5

[eluser]solid9[/eluser]
Thanks insiteFX, I already tried yours but the problem persist.

By the way below are the codes of the form
Code:
<table width="550" border='0'>
  <tr>
   <td bgcolor="cyan"><a href="#"><center><h2>Post</h2></center></a></td>
  </tr>
  <tr><td>
<center>
&lt;?php echo validation_errors(); ?&gt;
</center>
  
&lt;?php
  echo '<br>';
  echo form_open('main/process_post');
?&gt;
  <div id="register" align="center">
  <table width="550" bgcolor="#333333">
  <tr>
   <td align="left">Offering</td>
   <td align="left">
    &lt;?php
    //[swapid] => 14
       //[date_posted] => 2012-03-10
       //[offering] => eight
       //[seeking] => 8    

    if(!empty($swap->swapid)) {
     $offer = $swap->offering;
     $swapid = $swap->swapid;  
     form_hidden('swap_id', $swapid);    
    } else {
     $offer = '';
    }
    $data_form = array(
                  'name'        => 'offering',
                  'id'          => 'offering',
                  'value'       => $offer,
                  'rows'     => '15',
                  'cols'        => '55',
                );
        
    echo form_textarea($data_form);    
    ?&gt;
   </td>
  </tr>
  <tr>
   <td align="left">Seeking</td>
   <td align="left">
    &lt;?php  
    if(!empty($swap->swapid)) {
     $seek = $swap->seeking;
    } else {
     $seek = '';
    }
    $data_form = array(
                  'name'        => 'seeking',
                  'id'          => 'seeking',
                  'value'       => $seek,
                  'rows'     => '15',
                  'cols'        => '55',
                );
    
    echo form_textarea($data_form);    
    ?&gt;
   </td>
  </tr>
  <tr>
   <td align="left"></td>
   <td align="left">&lt;?php echo form_submit('mysubmit', 'Publish!'); ?&gt;</td>
  </div>
  </table>
&lt;?php
  echo form_close();
?&gt;
</td></tr>    
  <tr>
   <td><br><br></td>
  </tr>  
</table>

#6

[eluser]PhilTem[/eluser]
You're not echo-ing the form_hidden Wink
#7

[eluser]InsiteFX[/eluser]
And from the looks of it he's using an array for the values and then trying to access them as an object!
#8

[eluser]solid9[/eluser]
Thanks guys

specially PhilTem

WoW! I forgot the echo. LOL

Problem SOLVED.




Theme © iAndrew 2016 - Forum software by © MyBB