Fixed uncheck status not saved in Manage subscriptions page
Please note: Mandatory (required) checkbox Fields can not be Empty. This means the checkbox field can not be uncheck by the user. The admin can still control the status of the checkbox [MAILPOET-3858]
This commit is contained in:
committed by
Veljko V
parent
62cf852691
commit
2d32e5013e
@@ -191,6 +191,12 @@ class BlockRendererHelper {
|
||||
? $this->wp->escAttr(trim($block['params']['value'])) : '';
|
||||
}
|
||||
|
||||
public function getFieldIsRequired($block = []): bool {
|
||||
return (isset($block['params']['required'])
|
||||
&& strlen(trim($block['params']['required'])) > 0)
|
||||
? !empty($block['params']['required']) : false;
|
||||
}
|
||||
|
||||
public function getInputModifiers(array $block = []): string {
|
||||
$modifiers = [];
|
||||
|
||||
|
@@ -40,10 +40,15 @@ class Checkbox {
|
||||
);
|
||||
|
||||
$selectedValue = $this->rendererHelper->getFieldValue($block);
|
||||
$isFieldRequired = $this->rendererHelper->getFieldIsRequired($block);
|
||||
|
||||
foreach ($options as $option) {
|
||||
$hiddenValue = $isFieldRequired ? '1' : '0'; // Mandatory Fields can not be Empty
|
||||
$html .= '<input type="hidden" value="' . $hiddenValue . '" name="' . $fieldName . '" />';
|
||||
|
||||
$html .= '<label class="mailpoet_checkbox_label" '
|
||||
. $this->rendererHelper->renderFontStyle($formSettings) . '>';
|
||||
|
||||
$html .= '<input type="checkbox" class="mailpoet_checkbox" ';
|
||||
|
||||
$html .= 'name="' . $fieldName . '" ';
|
||||
|
Reference in New Issue
Block a user