single checkboxes aren't saving - not when editing in the view nor in the node itself.

I change them to radio buttons and they work fine.

Comments

jfall’s picture

This is a GREAT module - thanks!
I can confirm checkboxes don't seem to work - selecting works, but de-selecting does not save the de-selected state. Radio-buttons do work.
I'll have a look and see if i can find anything suspicious - got any ideas what perhaps to look for?

jfall’s picture

This is NOT a duplicate of http://drupal.org/node/235445 - I applied the patch, but it is not a fix for this bug, it deals with the checkbox default value. My checkboxes work just fine in the node edit form, just not the editablefields table.
And is NOT related to http://drupal.org/node/243266 - I disabled devel, bug persists...
Still hunting...

jfall’s picture

OK - here's what I tracked down...

Un-selected checkboxes don't seem to get posted with the form, so checkboxes don't get processed when they are not selected, thus you can't de-select them - Arggh...

Best I can tell, the form API (used by node-edit, for example) appears to take care of this, so the node-edit form works - shot in the dark, but I'd guess by simply noticing that the checkbox field didn't get posted back, so set a value of 0... hmmmmm????

Anyone got any bright ideas?

vacilando’s picture

Same problem...

boinkster’s picture

I run into the same issue. I can get by with radio buttons but a single check box would be so much cleaner...

Looks like required fields are similarly affected. i.e. a blank req. field has no impact on the form submit and returns blank fields after. That would be consistent with #3.

alxbridge’s picture

I've found you can work around this by overriding theme_checkbox, adding a hidden field containing the unchecked value before the checkbox:

function mytheme_checkbox($element) {
  _form_set_class($element, array('form-checkbox'));
  $checkbox = $element['#value'] ? sprintf('<input type="hidden" name="%s" id="%s" value="0" />', $element['#name'], $element['#id']) : '';
  $checkbox .= '<input ';
  ... [the rest as theme_checkbox]

Note that this only adds the hidden field if the current state of the checkbox is checked (i.e. if $element['#value'] is positive). If the hidden field is always put in, every item on the current page of the view gets updated instead of just those which have been checked/unchecked.

N.B. I've not tested this very thoroughly yet, so it may have knock-on effects on checkboxes elsewhere in your site.

mengi’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

Per https://drupal.org/node/2148735, 5.x is longer maintained so issue is closed.

mengi’s picture

Status: Closed (fixed) » Closed (won't fix)