views:

94

answers:

2

Hi,

How do I achieve this:

//view.php
<input type="hidden" name="Name" value="<?php echo $variable->id; ?>"

using CodeIgniter’s form_hidden helper:

//view.php
<?php echo form_hidden('Name','<?php echo $variable->id; ?>') ?>

The first one works fine when I display $variable->id but CI's form_hidden doesn't work.

+3  A: 

The form helpers are evaluated when the script is run, just like any other script, so you do this:

<?php echo form_hidden('Name', $variable->id); ?>

If you have shorttags enabled, you could do:
<?=form_hidden('Name', $variable->id);?>

ryeguy
+1 Thank you ryeguy. It worked!
01010011
A: 

This is the best and appropiate way to create hidden field in CI.

adsf
Opps... You left out the code adsf
01010011