Render styles for the form
[MAILPOET-2600] Signed-off-by: Pavel Dohnal <pavel@mailpoet.com>
This commit is contained in:
committed by
Jack Kitterhing
parent
b49ce7d4e4
commit
ce127eadc1
@ -37,7 +37,10 @@ class Renderer {
|
||||
|
||||
public function renderHTML(array $form = []): string {
|
||||
if (isset($form['body']) && !empty($form['body'])) {
|
||||
return $this->renderBlocks($form['body']);
|
||||
return $this->wrapForm(
|
||||
$this->renderBlocks($form['body']),
|
||||
$form['settings']
|
||||
);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@ -88,4 +91,23 @@ class Renderer {
|
||||
<input class="mailpoet_recaptcha_field" type="hidden" name="recaptcha">
|
||||
</div>';
|
||||
}
|
||||
|
||||
private function wrapForm(string $formBody, array $formSettings): string {
|
||||
$styles = [];
|
||||
|
||||
if (isset($formSettings['backgroundColor'])) {
|
||||
$styles[] = 'background-color: ' . trim($formSettings['backgroundColor']);
|
||||
}
|
||||
|
||||
if (isset($formSettings['fontColor'])) {
|
||||
$styles[] = 'color: ' . trim($formSettings['fontColor']);
|
||||
}
|
||||
|
||||
if (isset($formSettings['fontSize'])) {
|
||||
$styles[] = 'font-size: ' . trim($formSettings['fontSize']) . 'px';
|
||||
}
|
||||
|
||||
if (empty($styles)) return $formBody;
|
||||
return '<div style="' . join(';', $styles) . '">' . $formBody . '</div>';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user