Fix rendering issues in form blocks
[MAILPOET-3415]
This commit is contained in:
committed by
Veljko V
parent
6e911ffd1d
commit
c1aef842d2
@@ -4,6 +4,7 @@ namespace MailPoet\Form\Block;
|
||||
|
||||
use MailPoet\Form\BlockStylesRenderer;
|
||||
use MailPoet\Form\BlockWrapperRenderer;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Text {
|
||||
/** @var BlockRendererHelper */
|
||||
@@ -15,14 +16,19 @@ class Text {
|
||||
/** @var BlockWrapperRenderer */
|
||||
private $wrapper;
|
||||
|
||||
/** @var WPFunctions */
|
||||
private $wp;
|
||||
|
||||
public function __construct(
|
||||
BlockRendererHelper $rendererHelper,
|
||||
BlockStylesRenderer $inputStylesRenderer,
|
||||
BlockWrapperRenderer $wrapper
|
||||
BlockWrapperRenderer $wrapper,
|
||||
WPFunctions $wp
|
||||
) {
|
||||
$this->rendererHelper = $rendererHelper;
|
||||
$this->inputStylesRenderer = $inputStylesRenderer;
|
||||
$this->wrapper = $wrapper;
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
public function render(array $block, array $formSettings): string {
|
||||
@@ -33,7 +39,7 @@ class Text {
|
||||
}
|
||||
|
||||
if (in_array($block['id'], ['email', 'last_name', 'first_name'], true)) {
|
||||
$automationId = 'data-automation-id="form_' . $block['id'] . '" ';
|
||||
$automationId = 'data-automation-id="form_' . $this->wp->escAttr($block['id']) . '" ';
|
||||
}
|
||||
|
||||
$styles = $this->inputStylesRenderer->renderForTextInput($block['styles'] ?? [], $formSettings);
|
||||
@@ -57,7 +63,7 @@ class Text {
|
||||
$html .= 'value="' . $this->rendererHelper->getFieldValue($block) . '" ';
|
||||
|
||||
if ($styles) {
|
||||
$html .= 'style="' . $styles . '" ';
|
||||
$html .= 'style="' . $this->wp->escAttr($styles) . '" ';
|
||||
}
|
||||
|
||||
$html .= $automationId;
|
||||
|
Reference in New Issue
Block a user