Add default value to checkbox element on addElement method

Add default value to checkbox element on addElement method

by Lawrence Lagerlof -
Number of replies: 0

I am trying to create a list of checkboxes, each one with its specific ID, so I tried:

$mform->addElement('checkbox', 'groups[]', 'Group Two', null, array('value' => 2));

But the value above is not set to 2.

I tried to set the value of an unknown attribute:

$mform->addElement('checkbox', 'groups[]', 'Group Three', null, array('test' => 'test_value'));

And the attribute test is  correctly set to value test_value.

Said that, what I need to do to set the value of "value" attribute?

Thank you.


Average of ratings: -