When building a webform using options_element I noticed that an option with the value '0' could not be created. This is due to the filtering in _form_options_from_text(). Two changes in the first 10 lines were necessary to correct this:

$rows = array_filter(explode("\n", trim($text)), '_options_element_filter_options');

and

if (empty($row)&&!strlen($row)) {

This also uses a new function:

function _options_element_filter_options($value) {
return (bool)$value || strlen($value);
}

With these modifications, it correctly saves the '0' value.

Comments

liam morland’s picture

Status: Active » Needs review
StatusFileSize
new712 bytes

Here is a patch which does in effect the same as the changes above. It works for me.

quicksketch’s picture

Issue summary: View changes
Status: Needs review » Fixed

Thanks guys! Committed to both 1.x branches.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.