Refactor form blocks to use composition instead of inheritance
[MAILPOET-2665]
This commit is contained in:
committed by
Jack Kitterhing
parent
20926d56b7
commit
c6ca749cdc
@@ -2,27 +2,34 @@
|
||||
|
||||
namespace MailPoet\Form\Block;
|
||||
|
||||
class Textarea extends Base {
|
||||
class Textarea {
|
||||
/** @var Base */
|
||||
private $baseRenderer;
|
||||
|
||||
public function __construct(Base $baseRenderer) {
|
||||
$this->baseRenderer = $baseRenderer;
|
||||
}
|
||||
|
||||
public function render($block) {
|
||||
$html = '';
|
||||
|
||||
$html .= '<p class="mailpoet_paragraph">';
|
||||
|
||||
$html .= $this->renderLabel($block);
|
||||
$html .= $this->baseRenderer->renderLabel($block);
|
||||
|
||||
$lines = (isset($block['params']['lines']) ? (int)$block['params']['lines'] : 1);
|
||||
|
||||
$html .= '<textarea class="mailpoet_textarea" rows="' . $lines . '" ';
|
||||
|
||||
$html .= 'name="data[' . $this->getFieldName($block) . ']"';
|
||||
$html .= 'name="data[' . $this->baseRenderer->getFieldName($block) . ']"';
|
||||
|
||||
$html .= $this->renderInputPlaceholder($block);
|
||||
$html .= $this->baseRenderer->renderInputPlaceholder($block);
|
||||
|
||||
$html .= $this->getInputValidation($block);
|
||||
$html .= $this->baseRenderer->getInputValidation($block);
|
||||
|
||||
$html .= $this->getInputModifiers($block);
|
||||
$html .= $this->baseRenderer->getInputModifiers($block);
|
||||
|
||||
$html .= '>' . $this->getFieldValue($block) . '</textarea>';
|
||||
$html .= '>' . $this->baseRenderer->getFieldValue($block) . '</textarea>';
|
||||
|
||||
$html .= '</p>';
|
||||
|
||||
|
Reference in New Issue
Block a user