Backend\Classes\FormField
Overview
FormField definition is a translation of the form field configuration
Extends
- October\Rain\Element\Form\FieldDefinition
- October\Rain\Element\ElementBase
- October\Rain\Extension\Extendable
Implements
- Illuminate\Contracts\Support\Arrayable
- ArrayAccess
- Illuminate\Contracts\Support\Jsonable
- JsonSerializable
Public Properties
There are no public properties in the class.
Show inherited public properties
Inherited Public Properties
- $config - values for this instance. (defined in October\Rain\Element\ElementBase)
- $implement - extensions for this class. (defined in October\Rain\Extension\Extendable)
Protected Properties
There are no protected properties in the class.
Show inherited protected properties
Inherited Protected Properties
- $optionsCallback - (defined in October\Rain\Element\Form\FieldDefinition)
- $extensionData - contains class reflection information, including behaviors. (defined in October\Rain\Extension\Extendable)
- $extendableStaticMethods - is a collection of static methods used by behaviors. (defined in October\Rain\Extension\Extendable)
Public Methods
public __construct()
public __construct($config = [], $label = null): void
__construct using old and new interface
public getAttributes()
public getAttributes(string $position = 'field', $htmlBuild = true): array
getAttributes returns the attributes for this field at a given position.
public getCallableMethodFromValue()
public getCallableMethodFromValue($value): array|null
getCallableMethodFromValue checks for a string "Class::method" or as an array [Class, method] usually from a YAML definition
public getDefaultFromData()
public getDefaultFromData(mixed $data): mixed
getDefaultFromData returns the default value for this field, the supplied data is used to source data when defaultFrom is specified.
public getDisplayValue()
public getDisplayValue($value): void
getDisplayValue checks to see if display values (model attributes) should be translated, and also escapes the value
public getId()
public getId(string $suffix = null): string
getId returns a value suitable for the field id property.
public getName()
public getName(string $arrayName = null): string
getName returns a value suitable for the field name property. The array name is taken from the field or can be specified in the arguments.
public getOptionsFromModel()
public getOptionsFromModel($model, $fieldOptions, $data): void
getOptionsFromModel looks at the model for defined options.
public getTranslatableMessage()
public getTranslatableMessage(): string
public getValueFromData()
public getValueFromData(mixed $data, mixed $default = null): mixed
getValueFromData returns this fields value from a supplied data set, which can be an array or a model or another generic collection.
public hasAttribute()
public hasAttribute(string $name, string $position = 'field'): bool
hasAttribute checks if the field has the supplied [unfiltered] attribute.
public isSelected()
public isSelected(string $value = true): bool
isSelected determines if the provided value matches this field's value.
public nearestModelAttribute()
public nearestModelAttribute($model, $attribute = null): void
nearestModelAttribute returns the nearest model and attribute name of a nested attribute, which is useful for checking if an attribute is jsonable or a relation.
public resolveModelAttribute()
public resolveModelAttribute(string $attribute, $attribute = null): array
resolveModelAttribute returns the final model and attribute name of a nested attribute. Eg:
[$model, $attribute] = $this->resolveAttribute('person[phone]');
Inherited Public Methods
- __call() - handles dynamic calls to the element instance to set config. (defined in October\Rain\Element\ElementBase)
- __callStatic() - calls an undefined static method. (defined in October\Rain\Extension\Extendable)
- __get() - dynamically retrieves the value of an attribute. (defined in October\Rain\Element\ElementBase)
- __isset() - dynamically checks if an attribute is set. (defined in October\Rain\Element\ElementBase)
- __set() - dynamically sets the value of an attribute. (defined in October\Rain\Element\ElementBase)
- __sleep() - prepare the object for serialization. (defined in October\Rain\Extension\Extendable)
- __unset() - dynamically unsets an attribute. (defined in October\Rain\Element\ElementBase)
- __wakeup() - when a model is being unserialized, check if it needs to be booted. (defined in October\Rain\Extension\Extendable)
- addDynamicMethod() - programmatically adds a method to the extendable class. (defined in October\Rain\Extension\Extendable)
- addDynamicProperty() - programmatically adds a property to the extendable class. (defined in October\Rain\Extension\Extendable)
- asExtension() - is short hand for
getClassExtension()method, except takes the short. (defined in October\Rain\Extension\Extendable) - asOptionsDefinition() - optionsDefinition. (defined in October\Rain\Element\Form\FieldDefinition)
- clearExtendedClasses() - (defined in October\Rain\Extension\Extendable)
- displayAs() - type for this field. (defined in October\Rain\Element\Form\FieldDefinition)
- evalConfig() - override method. (defined in October\Rain\Element\ElementBase)
- extend() - this class with a closure. (defined in October\Rain\Extension\Extendable)
- extendClassWith() - dynamically extends a class with a specified behavior. (defined in October\Rain\Extension\Extendable)
- extendableCall() - magic method for
__call(). (defined in October\Rain\Extension\Extendable) - extendableCallStatic() - magic method for
__callStatic(). (defined in October\Rain\Extension\Extendable) - extendableConstruct() - should be called as part of the constructor. (defined in October\Rain\Extension\Extendable)
- extendableDestruct() - should be called when serializing the object. (defined in October\Rain\Extension\Extendable)
- extendableExtendCallback() - is a helper method for
::extend()static method. (defined in October\Rain\Extension\Extendable) - extendableGet() - magic method for
__get(). (defined in October\Rain\Extension\Extendable) - extendableSet() - magic method for
__set(). (defined in October\Rain\Extension\Extendable) - get() - an attribute from the element instance. (defined in October\Rain\Element\ElementBase)
- getClassExtension() - returns a behavior object from an extendable class, example:. (defined in October\Rain\Extension\Extendable)
- getClassMethodAsReflector() - (defined in October\Rain\Extension\Extendable)
- getClassMethods() - gets a list of class methods, extension equivalent of get_class_methods(). (defined in October\Rain\Extension\Extendable)
- getConfig() - returns the entire config array. (defined in October\Rain\Element\ElementBase)
- getDynamicProperties() - returns all dynamic properties and their values. (defined in October\Rain\Extension\Extendable)
- hasOptions() - returns true if options have been specified. (defined in October\Rain\Element\Form\FieldDefinition)
- implementClassWith() - will implement an extension using non-interference and should. (defined in October\Rain\Extension\Extendable)
- isClassExtendedWith() - checks if extendable class is extended with a behavior object. (defined in October\Rain\Extension\Extendable)
- isClassInstanceOf() - checks if the class implements the supplied interface methods. (defined in October\Rain\Extension\Extendable)
- jsonSerialize() - converts the object into something JSON serializable. (defined in October\Rain\Element\ElementBase)
- matchesContext() - returns true if the field matches the supplied context. (defined in October\Rain\Element\Form\FieldDefinition)
- methodExists() - checks if a method exists, extension equivalent of method_exists(). (defined in October\Rain\Extension\Extendable)
- offsetExists() - determines if the given offset exists. (defined in October\Rain\Element\ElementBase)
- offsetGet() - gets the value for a given offset. (defined in October\Rain\Element\ElementBase)
- offsetSet() - sets the value at the given offset. (defined in October\Rain\Element\ElementBase)
- offsetUnset() - unsets the value at the given offset. (defined in October\Rain\Element\ElementBase)
- options() - get/set for dropdowns, radio lists and checkbox lists. (defined in October\Rain\Element\Form\FieldDefinition)
- propertyExists() - checks if a property exists, extension equivalent of
property_exists(). (defined in October\Rain\Extension\Extendable) - span() - sets a side of the field on a form. (defined in October\Rain\Element\Form\FieldDefinition)
- toArray() - converts the element instance to an array. (defined in October\Rain\Element\ElementBase)
- toJson() - converts the element instance to JSON. (defined in October\Rain\Element\ElementBase)
- useConfig() - (defined in October\Rain\Element\Form\FieldDefinition)
Protected Methods
protected filterAttributes()
protected filterAttributes(
array $attributes,
string $position = 'field'
): array
filterAttributes adds any circumstantial attributes to the field based on other settings, such as the 'disabled' option.
protected filterPresetAttributes()
protected filterPresetAttributes(
array $attributes,
string $position = 'field'
): array
filterPresetAttributes adds attributes used specifically by the Input Preset API
protected filterTriggerAttributes()
protected filterTriggerAttributes(
array $attributes,
string $position = 'field'
): array
filterTriggerAttributes adds attributes used specifically by the Trigger API
protected getFieldNameFromData()
protected getFieldNameFromData(
string $fieldName,
mixed $data,
mixed $default = null
): mixed
getFieldNameFromData is an internal method to extract the value of a field name from a data set.
protected getOptionsFromModelAsDefault()
protected getOptionsFromModelAsDefault($model, $data): void
getOptionsFromModelAsDefault refers to the model method or any of its behaviors
protected getOptionsFromModelAsString()
protected getOptionsFromModelAsString($model, $methodName, $data): void
getOptionsFromModelAsString where options are an explicit method reference
protected initDefaultValues()
protected initDefaultValues(): void
initDefaultValues for this field
protected objectMethodExists()
protected objectMethodExists(object $object, string $method): boolean
objectMethodExists is an internal helper for method existence checks.
protected resolveModelAttributeInternal()
protected resolveModelAttributeInternal(
$model,
$attribute = null,
$options = []
): void
resolveModelAttributeInternal is an internal method resolver for resolveModelAttribute
Show inherited protected methods
Inherited Protected Methods
- extendableIsAccessible() - checks if a property is accessible, property equivalent. (defined in October\Rain\Extension\Extendable)
- extensionExtractImplements() - will return classes to implement. (defined in October\Rain\Extension\Extendable)
- extensionExtractMethods() - extracts the available methods from a behavior and adds it. (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromDynamicMethods() - (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromExtensions() - (defined in October\Rain\Extension\Extendable)