*/ trait ReadOnlyAttribute { /** * * @var boolean */ private $readonly = false; /** * Закрыто ли изменение поля * @return boolean */ public function isReadOnly() { return $this->readonly; } /** * Доступно ли поле для изменения * @return boolean */ public function isEditable() { return !$this->readonly; } /** * Помечает поле недоступным для изменения * @return $this */ public function setReadOnly() { $this->readonly = true; return $this; } /** * Помечает поле доступным для изменения * @return $this */ public function setEditable() { $this->readonly = false; return $this; } protected function appendReadOnlyAttribute(array & $attributes) { if ($this->readonly) { $attributes['readonly'] = null; } } }