Files
piratepoet/lib/Form/Block/Segment.php
Jan Jakeš 54549ff037 Convert variable names to camel case
[MAILPOET-1796]
2020-01-14 15:22:42 +01:00

43 lines
1.1 KiB
PHP

<?php
namespace MailPoet\Form\Block;
class Segment extends Base {
public static function render($block) {
$html = '';
$fieldName = 'data[' . static::getFieldName($block) . ']';
$fieldValidation = static::getInputValidation($block);
$html .= '<p class="mailpoet_paragraph">';
$html .= static::renderLabel($block);
$options = (!empty($block['params']['values'])
? $block['params']['values']
: []
);
foreach ($options as $option) {
if (!isset($option['id']) || !isset($option['name'])) continue;
$isChecked = (isset($option['is_checked']) && $option['is_checked']) ? 'checked="checked"' : '';
$html .= '<label class="mailpoet_checkbox_label">';
$html .= '<input type="checkbox" class="mailpoet_checkbox" ';
$html .= 'name="' . $fieldName . '[]" ';
$html .= 'value="' . $option['id'] . '" ' . $isChecked . ' ';
$html .= $fieldValidation;
$html .= ' /> ' . esc_attr($option['name']);
$html .= '</label>';
}
$html .= '<span class="mailpoet_error_' . $block['id'] . '"></span>';
$html .= '</p>';
return $html;
}
}