fixed both radio & checkbox fields so that it selects the proper value
This commit is contained in:
@ -18,6 +18,8 @@ class Checkbox extends Base {
|
|||||||
: array()
|
: array()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$selected_value = self::getFieldValue($block);
|
||||||
|
|
||||||
foreach($options as $option) {
|
foreach($options as $option) {
|
||||||
$html .= '<label class="mailpoet_checkbox_label">';
|
$html .= '<label class="mailpoet_checkbox_label">';
|
||||||
$html .= '<input type="hidden" name="'.$field_name.'" value="" />';
|
$html .= '<input type="hidden" name="'.$field_name.'" value="" />';
|
||||||
@ -28,9 +30,11 @@ class Checkbox extends Base {
|
|||||||
$html .= 'value="1" ';
|
$html .= 'value="1" ';
|
||||||
|
|
||||||
$html .= (
|
$html .= (
|
||||||
(isset($option['is_checked']) && $option['is_checked'])
|
(
|
||||||
||
|
$selected_value === ''
|
||||||
(self::getFieldValue($block))
|
&& isset($option['is_checked'])
|
||||||
|
&& $option['is_checked']
|
||||||
|
) || ($selected_value === $value)
|
||||||
) ? 'checked="checked"' : '';
|
) ? 'checked="checked"' : '';
|
||||||
|
|
||||||
$html .= $field_validation;
|
$html .= $field_validation;
|
||||||
|
@ -18,6 +18,8 @@ class Radio extends Base {
|
|||||||
: array()
|
: array()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$selected_value = self::getFieldValue($block);
|
||||||
|
|
||||||
foreach($options as $option) {
|
foreach($options as $option) {
|
||||||
$html .= '<label class="mailpoet_radio_label">';
|
$html .= '<label class="mailpoet_radio_label">';
|
||||||
|
|
||||||
@ -36,9 +38,11 @@ class Radio extends Base {
|
|||||||
$html .= 'value="'.esc_attr($value).'" ';
|
$html .= 'value="'.esc_attr($value).'" ';
|
||||||
|
|
||||||
$html .= (
|
$html .= (
|
||||||
(isset($option['is_checked']) && $option['is_checked'])
|
(
|
||||||
||
|
$selected_value === ''
|
||||||
(self::getFieldValue($block) === $value)
|
&& isset($option['is_checked'])
|
||||||
|
&& $option['is_checked']
|
||||||
|
) || ($selected_value === $value)
|
||||||
) ? 'checked="checked"' : '';
|
) ? 'checked="checked"' : '';
|
||||||
|
|
||||||
$html .= $field_validation;
|
$html .= $field_validation;
|
||||||
|
Reference in New Issue
Block a user