21278 Posts in 5728 Topics by 2599 members
General Questions
SilverStripe Forums » General Questions » (solved)CheckboxField unchecked as default in front end doesn't work
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 158 Views |
-
(solved)CheckboxField unchecked as default in front end doesn't work

1 November 2012 at 10:55pm Last edited: 7 November 2012 11:33pm
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)
| 158 Views | ||
|
Page:
1
|
Go to Top |

