753 Posts in 310 Topics by 289 members
| Go to End | ||
| Author | Topic: | 4053 Views |
-
Re: Checkboxes in widget don't save their checked values

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?
-
Re: Checkboxes in widget don't save their checked values

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.
-
Re: Checkboxes in widget don't save their checked values

21 July 2012 at 1:57am Last edited: 25 July 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;
}
}parent::populateFromPostData($data);
} -
Re: Checkboxes in widget don't save their checked values

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.
| 4053 Views | ||
| Go to Top |


