I don’t understand, what U explain me with this statement. I want to be checked checkBox. As it seems ,U assign value to propertie. How sholud this operate?
Where sholud I code like this - in Controller or in formular?
$ZMailAusgangEmpfaenger->id_empfaenger_art = [1];
[size=“2”]Remember: I don’t want to set default value. I just wanne activate checkbox in formular[/size]
In the above, $ZMailAusgangEmpfaenger is the model for the form and ‘id_empfaenger_art’ is the attribute for the field which should receive the ids that the user has selected with the checkbox list.
We can set a default set of selected ids to the field before we render the form, probably somewhere in the controller (it doesn’t matter much).
That’s it. It should render the ‘an:’ checkbox checked.
I don’t understand what you mean by this. What’s the difference between ‘checked by default’ and ‘activated’?
This means, that default value will be written into database without signing up in formuar. Activating checkBox means, that user will see check-box fiield, which is activated. Saving value into database is same in both cases…
As I said, set the default values (or, initial values) to the attribute of the model before you render the checkbox list, then you will see the corresponding checkboxes initially checked (or, activated, in your term) in the form.
// check 'an:' and 'bc:' by default
$ZMailAusgangEmpfaenger->id_empfaenger_art = [1, 2];
BTW, could you show us what ‘id_empfaenger_art’ attribute is like? As you see in the example code, ‘id_empfaenger_art’ must hold an array of ids.
As U can see, id_empfaenger_art doesn’t hold an array of ids. It holds an array, whether checkBox has been checked or not checked. In this case, all checkBoxes have been checked. I assume, that’s what U wanted to say with ‘array of ids’, isn’t it?
For me, [size=“2”]‘array of ids’ means array of PrimaryKey…[/size]
[size=“2”]In any case, ur suggestion doesn’t work. I code like this both,in Controller and in formular:[/size]