CodeIgniter form_hidden

How to achieve this:

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

using CodeIgniters form_hidden helper:

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

The first one works fine when I show $ variable-> id, but CI form_hidden is not working.

+3
source share
2 answers

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

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

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

+5
source

The following is complete information for the CodeIgniter form helper class:
http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

+2
source

Source: https://habr.com/ru/post/1743763/


All Articles