fixed both radio & checkbox fields so that it selects the proper value

This commit is contained in:
Jonathan Labreuille
2016-07-01 13:52:12 +02:00
parent 5eef709af5
commit 9de3a245b0
2 changed files with 14 additions and 6 deletions

View File

@ -18,6 +18,8 @@ class Checkbox extends Base {
: array()
);
$selected_value = self::getFieldValue($block);
foreach($options as $option) {
$html .= '<label class="mailpoet_checkbox_label">';
$html .= '<input type="hidden" name="'.$field_name.'" value="" />';
@ -28,9 +30,11 @@ class Checkbox extends Base {
$html .= 'value="1" ';
$html .= (
(isset($option['is_checked']) && $option['is_checked'])
||
(self::getFieldValue($block))
(
$selected_value === ''
&& isset($option['is_checked'])
&& $option['is_checked']
) || ($selected_value === $value)
) ? 'checked="checked"' : '';
$html .= $field_validation;