Class luya\admin\ngrest\aw\ActiveWindowFormField
Inheritance | luya\admin\ngrest\aw\ActiveWindowFormField » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable |
Available since version | 1.2.2 |
Source Code | https://github.com/luyadev/luya-module-admin/blob/master/src/ngrest/aw/ActiveWindowFormField.php |
ActiveWindow ActiveField Configration
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$attribute | string | The attribute name of the field is isued as identifier to send the post data. | luya\admin\ngrest\aw\ActiveWindowFormField |
$form | luya\admin\ngrest\aw\ActiveWindowFormWidget | The form widget object | luya\admin\ngrest\aw\ActiveWindowFormField |
$label | string|boolean | A label which is used when no label is provided from class creation config | luya\admin\ngrest\aw\ActiveWindowFormField |
$value | string | Pre defined value of the option | luya\admin\ngrest\aw\ActiveWindowFormField |
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$element | luya\admin\helpers\AngularObject | The angular object element which is taken to generate the input. | luya\admin\ngrest\aw\ActiveWindowFormField |
$parts | array | An array with key and value. | luya\admin\ngrest\aw\ActiveWindowFormField |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\BaseObject |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of an object property. | yii\base\BaseObject |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() | Sets value of an object property. | yii\base\BaseObject |
__toString() | When the element is directly forced to echo its output this method is called and the template will be
render with the render() method. |
luya\admin\ngrest\aw\ActiveWindowFormField |
__unset() | Sets an object property to null. | yii\base\BaseObject |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
checkbox() | Checkbox input | luya\admin\ngrest\aw\ActiveWindowFormField |
checkboxList() | Checkbox list input | luya\admin\ngrest\aw\ActiveWindowFormField |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
datePicker() | Date picker | luya\admin\ngrest\aw\ActiveWindowFormField |
datetimePicker() | Date time picker | luya\admin\ngrest\aw\ActiveWindowFormField |
dropDownList() | Generate a select dropdown with data as array. | luya\admin\ngrest\aw\ActiveWindowFormField |
fileUpload() | File upload | luya\admin\ngrest\aw\ActiveWindowFormField |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
hint() | The method to set a hint value for the current render AngularObject element. | luya\admin\ngrest\aw\ActiveWindowFormField |
imageUpload() | Image upload | luya\admin\ngrest\aw\ActiveWindowFormField |
init() | luya\admin\ngrest\aw\ActiveWindowFormField | |
initValue() | Add a default value when initializing. | luya\admin\ngrest\aw\ActiveWindowFormField |
label() | Define a label for this field. If false, no label will be used, if a label is provided from the configration object (form) this will be overritten by this method. | luya\admin\ngrest\aw\ActiveWindowFormField |
passwordInput() | Passwword input field | luya\admin\ngrest\aw\ActiveWindowFormField |
radioList() | Radio list input | luya\admin\ngrest\aw\ActiveWindowFormField |
render() | Render the template based on input values of $parts. | luya\admin\ngrest\aw\ActiveWindowFormField |
textInput() | Text input field | luya\admin\ngrest\aw\ActiveWindowFormField |
textarea() | Create textarea | luya\admin\ngrest\aw\ActiveWindowFormField |
Protected Methods
Method | Description | Defined By |
---|---|---|
getNgModel() | luya\admin\ngrest\aw\ActiveWindowFormField |
Property Details
The attribute name of the field is isued as identifier to send the post data.
The angular object element which is taken to generate the input.
The form widget object
A label which is used when no label is provided from class creation config
Method Details
Defined in: yii\base\BaseObject::__call()
Calls the named method which is not a class method.
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
public mixed __call ( $name, $params ) | ||
$name | string |
The method name |
$params | array |
Method parameters |
return | mixed |
The method return value |
---|---|---|
throws | yii\base\UnknownMethodException |
when calling unknown method |
public function __call($name, $params)
{
throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}
Defined in: yii\base\BaseObject::__construct()
Constructor.
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call init().
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
public void __construct ( $config = [] ) | ||
$config | array |
Name-value pairs that will be used to initialize the object properties |
public function __construct($config = [])
{
if (!empty($config)) {
Yii::configure($this, $config);
}
$this->init();
}
Defined in: yii\base\BaseObject::__get()
Returns the value of an object property.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
See also __set().
public mixed __get ( $name ) | ||
$name | string |
The property name |
return | mixed |
The property value |
---|---|---|
throws | yii\base\UnknownPropertyException |
if the property is not defined |
throws | yii\base\InvalidCallException |
if the property is write-only |
public function __get($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter();
} elseif (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
}
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}
Defined in: yii\base\BaseObject::__isset()
Checks if a property is set, i.e. defined and not null.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
public boolean __isset ( $name ) | ||
$name | string |
The property name or the event name |
return | boolean |
Whether the named property is set (not null). |
---|
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter() !== null;
}
return false;
}
Defined in: yii\base\BaseObject::__set()
Sets value of an object property.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
See also __get().
public void __set ( $name, $value ) | ||
$name | string |
The property name or the event name |
$value | mixed |
The property value |
throws | yii\base\UnknownPropertyException |
if the property is not defined |
---|---|---|
throws | yii\base\InvalidCallException |
if the property is read-only |
public function __set($name, $value)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter($value);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}
}
When the element is directly forced to echo its output this method is called and the template will be
render with the render()
method.
public string __toString ( ) |
public function __toString()
{
return $this->render();
}
Defined in: yii\base\BaseObject::__unset()
Sets an object property to null.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
public void __unset ( $name ) | ||
$name | string |
The property name |
throws | yii\base\InvalidCallException |
if the property is read only. |
---|
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter(null);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
}
}
Defined in: yii\base\BaseObject::canGetProperty()
Returns a value indicating whether a property can be read.
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also canSetProperty().
public boolean canGetProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property can be read |
---|
public function canGetProperty($name, $checkVars = true)
{
return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}
Defined in: yii\base\BaseObject::canSetProperty()
Returns a value indicating whether a property can be set.
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also canGetProperty().
public boolean canSetProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property can be written |
---|
public function canSetProperty($name, $checkVars = true)
{
return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}
Checkbox input
public \luya\admin\ngrest\aw\ActiveField checkbox ( array $options = [] ) | ||
$options |
public function checkbox(array $options = [])
{
$this->element = Angular::checkbox('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
Checkbox list input
public \luya\admin\ngrest\aw\ActiveField checkboxList ( array $data, array $options = [] ) | ||
$data | array |
The items |
$options |
public function checkboxList(array $data, array $options = [])
{
$this->element = Angular::checkboxArray('{model}', '{label}', $data, array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
::class
instead.
Defined in: yii\base\BaseObject::className()
Returns the fully qualified name of this class.
public static string className ( ) | ||
return | string |
The fully qualified name of this class. |
---|
public static function className()
{
return get_called_class();
}
Date picker
public \luya\admin\ngrest\aw\ActiveField datePicker ( array $options = [] ) | ||
$options |
public function datePicker(array $options = [])
{
$this->element = Angular::date('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
Date time picker
public \luya\admin\ngrest\aw\ActiveField datetimePicker ( array $options = [] ) | ||
$options |
public function datetimePicker(array $options = [])
{
$this->element = Angular::datetime('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
Generate a select dropdown with data as array.
public \luya\admin\ngrest\aw\ActiveField dropDownList ( array $data, array $options = [] ) | ||
$data | array | |
$options | array |
public function dropDownList(array $data, array $options = [])
{
$this->element = Angular::select('{model}', '{label}', $data, array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
File upload
public \luya\admin\ngrest\aw\ActiveField fileUpload ( array $options = [] ) | ||
$options |
public function fileUpload(array $options = [])
{
$this->element = Angular::fileUpload('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
protected string getNgModel ( ) |
protected function getNgModel()
{
return 'params.'.$this->attribute;
}
Defined in: yii\base\BaseObject::hasMethod()
Returns a value indicating whether a method is defined.
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
public boolean hasMethod ( $name ) | ||
$name | string |
The method name |
return | boolean |
Whether the method is defined |
---|
public function hasMethod($name)
{
return method_exists($this, $name);
}
Defined in: yii\base\BaseObject::hasProperty()
Returns a value indicating whether a property is defined.
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also:
public boolean hasProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property is defined |
---|
public function hasProperty($name, $checkVars = true)
{
return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}
The method to set a hint value for the current render AngularObject element.
public \luya\admin\ngrest\aw\ActiveField hint ( $text ) | ||
$text | string |
The hint text to display. |
public function hint($text)
{
$this->element->hint($text);
return $this;
}
Image upload
public \luya\admin\ngrest\aw\ActiveField imageUpload ( array $options = [] ) | ||
$options |
public function imageUpload(array $options = [])
{
$this->element = Angular::imageUpload('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
public void init ( ) |
public function init()
{
parent::init();
// set text input as default element
$this->textInput();
}
Add a default value when initializing.
public \luya\admin\ngrest\aw\ActiveField initValue ( $value ) | ||
$value | string|integer |
public function initValue($value)
{
if (empty($value)) {
$this->parts['{initValue}'] = '';
} else {
$this->parts['{initValue}'] = "{model}='{$value}'";
}
return $this;
}
Define a label for this field. If false, no label will be used, if a label is provided from the configration object (form) this will be overritten by this method.
public \luya\admin\ngrest\aw\ActiveField label ( $label ) | ||
$label | string |
The label of the element |
public function label($label)
{
if ($label === false) {
$this->parts['{label}'] = '';
} else {
$this->parts['{label}'] = $label;
}
return $this;
}
Passwword input field
public \luya\admin\ngrest\aw\ActiveField passwordInput ( array $options = [] ) | ||
$options | array |
Optional data for the text input array. |
public function passwordInput(array $options = [])
{
$this->element = Angular::password('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
Radio list input
public \luya\admin\ngrest\aw\ActiveField radioList ( array $data, array $options = [] ) | ||
$data | array |
The items |
$options |
public function radioList(array $data, array $options = [])
{
$this->element = Angular::radio('{model}', '{label}', $data, array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
Render the template based on input values of $parts.
public string render ( ) | ||
return | string |
The rendered field element. |
---|
public function render()
{
if (!isset($this->parts['{label}'])) {
$this->label($this->label);
}
if (!isset($this->parts['{initValue}'])) {
$this->initValue(null);
}
return str_replace([
'{label}', '{initValue}', '{model}',
], [
$this->parts['{label}'],
$this->parts['{initValue}'],
$this->getNgModel(),
], $this->element) . PHP_EOL;
}
Text input field
public \luya\admin\ngrest\aw\ActiveField textInput ( array $options = [] ) | ||
$options | array |
Optional data for the text input array. |
public function textInput(array $options = [])
{
$this->element = Angular::text('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}
Create textarea
public \luya\admin\ngrest\aw\ActiveField textarea ( array $options = [] ) | ||
$options | array |
Optional data for the textarea input |
public function textarea(array $options = [])
{
$this->element = Angular::textarea('{model}', '{label}', array_merge($options, [
'fieldid' => $this->form->getFieldId($this->attribute),
'ng-init' => '{initValue}',
]));
return $this;
}