CakePHP 3 - Creating hiddenField

According to the documentation

http://book.cakephp.org/3.0/en/views/helpers/form.html#options-for-select-checkbox-and-radio-inputs

I use "HiddenField" to create a hidden input with a value of 0 .. Like this

 echo $this->Form->Label("Stats ");            
                echo $this->Form->checkbox('stats', [
                                'value' => '1',
                                'hiddenField' => '0',
                            ]);

My HTML (no hidden field) as it should:

<input type="checkbox" name="stats" value="1" required="required">

I did it yesterday, but today it does not work, and I have not updated the version of the cake. NOTHING, Crazy: \

+4
source share
2 answers

You did it wrong according to the syntax.

Use the following, which I tested on localhost:

echo $this->Form->checkbox('stats',array(
                                'value' => '1',
                                'hiddenField' => true,
                            ));

: hiddenField' => '0', , 0, PHP false ( PHP). .

:

<input type="hidden" name="data[CourseCategory][stats]" id="CourseCategoryStats_" value="0">
<input type="checkbox" name="data[CourseCategory][stats]" value="1" id="CourseCategoryStats">
+2

= 0 echo $this- > Form- > checkbox ('done');

-1

All Articles