Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[SOLVED] Bug? Disabled checkboxes loosing value


Reply

3 Posts   238 Views

Avatar
Bereusei

25 January 2014 at 12:48am Community Member, 94 Posts

Hey guys,

I checked this phenomenon on serveral Silverstripe 3.1. websites, but want to be sure, that it´s really a bug from silverstripe.

If I have a checked disabled checkbox

<input id="Form_ItemEditForm_Categories_27" class="checkbox" name="Categories[27]" type="checkbox" value="27" checked="checked" disabled="disabled">


in the backend/modeladmin and I save the entry, the checkbox loose the value, in other word it´s "check".

Can anyone check this phenomenon at his own framework? I could generate this error simple with the google-webdeveloper tool by adding disabled="disabled" into <input>

Avatar
kinglozzer

25 January 2014 at 4:05am Community Member, 148 Posts

Hi Bereusei,

Default browser behaviour is to not include disabled fields in POST data, so that's what's causing this. If you need to use disabled form inputs in the CMS, the best way to do it is to include some custom JavaScript to re-enable the field on form submit.

Avatar
Bereusei

25 January 2014 at 5:57am Community Member, 94 Posts

Thanks for the info, kinglozzer. Doesn't make any sense for me why browsers don't do this, but ok. I found a workaround for my problem. Thanks for the help.