So i have this field i want to keep hidden in my form.
For this purpose i have tried the following:
<?php echo $this->Form->input('group_id', array('hiddenField' => true, 'value'=> 2)); ?>
I also tried:
<?php echo $this->Form->input('group_id', array('options' => array('hiddenField'=> 'true'), 'value'=>2 )); ?>
How ever i still see the input field..
What am i doing wrong?
The Html. Hidden() method generates a input hidden field element with specified name, value and html attributes.
$data = $this->request->data; $someVariable = $data["name"]; Or, you can access any field directly, by using data() accessor: $someVariable = $this->request->data("name"); From this point, you can do anything you want with this variable.
The FormHelper focuses on creating forms quickly, in a way that will streamline validation, re-population and layout. The FormHelper is also flexible - it will do almost everything for you using conventions, or you can use specific methods to get only what you need.
You misread the documentation, I assume.
hiddenField
is to enable/disable specific hidden fields for specific form fields.
You are either looking for
$this->Form->hidden('group_id')
or
$this->Form->input('group_id', ['type' => 'hidden']);
I usually only use the latter.
See http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html
BUT - that said - you shouldnt actually use either one of those. And omit any fields that serve no real purpose for the view and its form. Instead you should inject those fields into the data array prior to saving. See http://www.dereuromark.de/2010/06/23/working-with-forms/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With