Marc Rasmussen Marc Rasmussen - 1 year ago 89
PHP Question

Cakephp hidden input field

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?


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->input('group_id', array('type' => 'hidden');

I usually only use the latter.


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