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.1 KiB
PHP
65 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Artmark\Forms\Attributes;
|
|
|
|
/**
|
|
* Description of DisabledAttribute
|
|
*
|
|
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
|
*/
|
|
trait DisabledAttribute
|
|
{
|
|
/**
|
|
*
|
|
* @var boolean
|
|
*/
|
|
private $disabled = false;
|
|
|
|
/**
|
|
* Выключено ли поле
|
|
* @return boolean
|
|
*/
|
|
public function isDisabled()
|
|
{
|
|
return $this->disabled;
|
|
}
|
|
|
|
/**
|
|
* Включено ли поле
|
|
* @return boolean
|
|
*/
|
|
public function isEnabled()
|
|
{
|
|
return !$this->disabled;
|
|
}
|
|
|
|
/**
|
|
* Выключает поле
|
|
* @return $this
|
|
*/
|
|
public function disable()
|
|
{
|
|
$this->disabled = true;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Включает поле
|
|
* @return $this
|
|
*/
|
|
public function enable()
|
|
{
|
|
$this->disabled = false;
|
|
|
|
return $this;
|
|
}
|
|
|
|
protected function appendDisabledAttribute(array & $attributes)
|
|
{
|
|
if ($this->disabled) {
|
|
$attributes['disabled'] = null;
|
|
}
|
|
}
|
|
}
|