Hi,
I am new to silverstripe, php and here...
I have a question regarding the difference between back end and front end behaviour of the CheckboxField.
My problem:
function getCMSFields() {
$fields = new FieldSet( ...
new CheckboxField('Question','Do you want to show this?', array(
'true' => 'yes', 'false' => 'no')),
....
);
works like I expected the box is not ticked here in the back end,
but if I use the same field for the front end
function Form() {
$fields = new FieldSet(...
new CheckboxField('Question','Do you want to show this?', array(
'true' => 'yes', 'false' => 'no')),
....
);
the box is ticked.
I tried various combinations like
1. $fields = new FieldSet(...
new CheckboxField('Question','Do you want to show this?', array(
'true' => 'yes', 'false' => 'no'), false),
....
);
2. $fields = new FieldSet(...
new CheckboxField('Question','Do you want to show this?', array(
'true' => 'yes', 'false' => 'no'), 0),
....
);
3. static $defaults = array(
'Question' => 0
);
4. static $defaults = array(
'Question' => false
);
nothing works...
Is this a bug or what am I missing?
I use SilverStripe 2.4.
any ideas?
maybe I should mention that I use the backend (function getCMSFields() {...) in DataObject
STUPID ME I changed a former OptionsetField into CheckboxField and it's simply:
$fields = new FieldSet(...
new CheckboxField('Question','Do you want to show this?'), ...
just a matter of copy and paste and not thinking properly error! - maybe somebody else will have the same problem, so I leave it posted - these mistakes to find just take so much time
...and I guess the most irritating was, that it worked properly in the back end (CMS fields)