You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.2 KiB
PHP
65 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Artmark\Forms\Attributes;
|
|
|
|
/**
|
|
* Description of ReadOnlyAttribute
|
|
*
|
|
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
|
*/
|
|
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;
|
|
}
|
|
}
|
|
}
|