From 5e19d3bada9dbccfd95da11ad0ee8b09040068a5 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 15 Jun 2018 14:57:07 +0200 Subject: [PATCH] BaseFormElement: move attribute callbacks to... ...dedicated methods, this allows to override them --- .../ipl/Html/FormElement/BaseFormElement.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/vendor/ipl/Html/FormElement/BaseFormElement.php b/library/vendor/ipl/Html/FormElement/BaseFormElement.php index db50241b..2db0efad 100644 --- a/library/vendor/ipl/Html/FormElement/BaseFormElement.php +++ b/library/vendor/ipl/Html/FormElement/BaseFormElement.php @@ -41,10 +41,18 @@ abstract class BaseFormElement extends BaseHtmlElement /** * Link constructor. * @param $name - * @param $value * @param \dipl\Html\Attributes|array|null $attributes */ public function __construct($name, $attributes = null) + { + $this->registerAttributeCallbacks(); + if ($attributes !== null) { + $this->addAttributes($attributes); + } + $this->setName($name); + } + + protected function registerAttributeCallbacks() { $this->getAttributes() ->registerAttributeCallback('label', [$this, 'getNoAttribute'], [$this, 'setLabel']) @@ -53,10 +61,6 @@ abstract class BaseFormElement extends BaseHtmlElement ->registerAttributeCallback('description', [$this, 'getNoAttribute'], [$this, 'setDescription']) ->registerAttributeCallback('validators', null, [$this, 'setValidators']) ->registerAttributeCallback('required', [$this, 'getRequiredAttribute'], [$this, 'setRequired']); - if ($attributes !== null) { - $this->addAttributes($attributes); - } - $this->setName($name); } /**