setMaxLength($maxLength); } if($form) { $this->setForm($form); } parent::__construct($name, $title, $value); } /** * @param int $maxLength * * @return static */ public function setMaxLength($maxLength) { $this->maxLength = $maxLength; return $this; } /** * @return null|int */ public function getMaxLength() { return $this->maxLength; } /** * @return array */ public function getAttributes() { $maxLength = $this->getMaxLength(); $attributes = array(); if($maxLength) { $attributes['maxLength'] = $maxLength; $attributes['size'] = min($maxLength, 30); } return array_merge( parent::getAttributes(), $attributes ); } /** * @return string */ public function InternallyLabelledField() { if(!$this->value) { $this->value = $this->Title(); } return $this->Field(); } }