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.

Widgets /

Discuss SilverStripe Widgets.

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

Checkboxes in widget don't save their checked values

Go to End

12 Posts   7062 Views


Community Member, 5 Posts

13 January 2011 at 9:39pm

Hi Artyom, I was having the same issue with CheckboxField's and HTMLEditorField's on widget editors on SS 2.4.4, and I was really hoping your fix would do the trick. So I applied your patch from ticket 6288. It doesn't work for me because the patched code now throws this:

[User Error] Uncaught Exception: Object->__call(): the method 'setcmsform' does not exist on 'Widget_LatestBlogPosts'

The relevant code from the patched file: cms/code/WidgetAreaEditor.php line 52:

		foreach($widgets as $widget) {
			$widget->setCMSForm($this->form);     // <-- ????

Doing a search, there is no setCMSForm() function or CMSForm property anywhere in the entire SS 2.4.4 install. Where does setCMSForm() exist for you?


Community Member, 5 Posts

13 January 2011 at 10:03pm

Hi FungshuiElephant, I realize you wrote your fix over a year ago, but I applied your code to Widget.php to a fresh SS 2.4.4 install and the issue still remains--CheckboxField's still do not save their state properly.


Community Member, 6 Posts

21 July 2012 at 1:57am

Edited: 25/07/2012 10:47am

A simple solution would be to override Widget Class or Decorated it. You just need to override populateFromPostData() method and set to "0" the Boolean fields that are not passed in $_POST because unchecked. Using onBeforeWrite has the same effect.

function populateFromPostData($data)

	foreach (DataObject::database_fields($this->class) as $name=>$type) {
		if ( (strpos($type, 'Boolean')!==false) and !isset($data[$name])) {
			$data[$name] = 0;



Community Member, 34 Posts

2 December 2012 at 3:32am

I just came across this post again when working on a clients older site and it saved my butt yet again. Just saying thanks! The fix that FungshuiElephant posted works for SS 2.3.13 as well.

Go to Top