lundi 1 janvier 2018

CakePHP 3 - Set checkbox to checked in edit view

maybe I'm blind on the point but I'm struggling for over an hour and can not find a solution.

My goal is in edit view a checkbox, which is set in the database to "yes", also to be displayed as checked.

My InputField looks like this:

<?php
    echo $this->Form->checkbox(
        'active',[
            'value'=>'yes',
            'hiddenField'=>'no'
        ]
    );
?>

Saving the values, works. But if the value "Yes" is saved, I call the edit view again, the checkbox is not marked as checked.

Is there any way to get around this? Would be more pleasant for the corresponding user as in the remaining input fields to get the value issued.

Do you have an idea or an approach?

Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire