Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter's form_hidden

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.

like image 780
Anthony Avatar asked Apr 15 '26 01:04

Anthony


2 Answers

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);?>

like image 125
ryeguy Avatar answered Apr 16 '26 14:04

ryeguy


Here are the complete details for the form helper class of CodeIgniter:
https://www.codeigniter.com/user_guide/helpers/form_helper.html

like image 39
Khandad Niazi Avatar answered Apr 16 '26 13:04

Khandad Niazi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!