Select
Representation of a select element.
- Full name:
\Qubus\Form\FormBuilder\Select - Parent class:
\Qubus\Form\FormBuilder\Choice
Methods
__construct
Parameters:
| Parameter | Type | Description |
|---|---|---|
$options | array | Element options |
$attr | array | HTML attributes |
Throws:
renderContent
Render the content of the HTML element.
renderElement
Render the select.
Inherited methods
__construct
Parameters:
| Parameter | Type | Description |
|---|---|---|
$options | array | Element options |
$attr | array | HTML attributes |
Throws:
addDecorator
Add a decorator to the element.
public addDecorator(string|\Qubus\Form\FormBuilder\Decorator $decorator): \Qubus\Form\FormBuilder\Element
Parameters:
| Parameter | Type | Description |
|---|---|---|
$decorator | string|\Qubus\Form\FormBuilder\Decorator | Decorator object or name |
Return Value:
$this
applyDeepDecorators
Apply decorators from parent
Parameters:
| Parameter | Type | Description |
|---|---|---|
$parent | \Qubus\Form\FormBuilder\Group |
getDecorators
Get all decorators
convertCustomType
Convert custom (form specific) type to general factory type.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$type | string | (in/out) Element type |
$options | array | (in/out) Element options |
$attr | array | (in/out) HTML attributes |
build
Factory method
Parameters:
| Parameter | Type | Description |
|---|---|---|
$type | string | Element type |
$options | array | Element options |
$attr | array | HTML attributes |
Throws:
getForm
Get the form to which this element is added.
public getForm(): \Qubus\Form\FormBuilder\Group|\Qubus\Form\FormBuilder\Element|\Qubus\Form\Form|null
asComponentOf
Set element of which this a component of
Parameters:
| Parameter | Type | Description |
|---|---|---|
$element | \Qubus\Form\FormBuilder\Element |
Return Value:
$this
isComponent
Check if element is used as a component
setParent
Set parent element
Parameters:
| Parameter | Type | Description |
|---|---|---|
$parent | \Qubus\Form\FormBuilder\Element |
Return Value:
$this
Throws:
getParent
Return parent element
end
Get parent or element of which this is an component.
getId
Get element id.
getName
Return the name of the control.
setAttr
Set HTML attribute(s).
- This method is final. Parameters:
| Parameter | Type | Description |
|---|---|---|
$attr | array|string | Attribute name or assoc array with attributes |
$value | mixed|null |
Return Value:
$this
getAttr
Get an HTML attribute(s).
All attributes will be cased to their string representation.
- This method is final. Parameters:
| Parameter | Type | Description |
|---|---|---|
$attr | string|null | Attribute name, omit to get all attributes |
hasClass
Check if class is present
- This method is final. Parameters:
| Parameter | Type | Description |
|---|---|---|
$class | string |
addClass
Add a class
- This method is final. Parameters:
| Parameter | Type | Description |
|---|---|---|
$class | array|string | Multiple classes may be specified as array or using a space |
Return Value:
$this
removeClass
Remove a class
Parameters:
| Parameter | Type | Description |
|---|---|---|
$class | array|string | Multiple classes may be specified as array or using a space |
Return Value:
$this
setOption
Set an option or array with options
Parameters:
| Parameter | Type | Description |
|---|---|---|
$option | array|string | Option name or array with options |
$value | mixed|null |
Return Value:
$this
getOption
Get an option.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$option | string |
getOptions
Get all options.
Bubbles to combine options of parent/ancestors.
isValid
Validate the element.
- This method is final.
validate
Validate the control.
setContent
Set element content
Parameters:
| Parameter | Type | Description |
|---|---|---|
$content | \Closure|string | Content as HTML |
getContent
Get the element content
- This method is final.
renderContent
Render the element content
render
Render the element to HTML.
Throws:
toHTML
Render the element to HTML.
- This method is final.
__toString
Render the element to HTML.
- This method is final.
parse
Parse a message, inserting values for placeholders.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$message | string |
resolvePlaceholder
Get a value for a placeholder.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$var | string |
convertTo
Convert an element to another type.
Simply returns $this if element is already of correct type.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$type | string |
__clone
Magic method called after cloning element
onClone
Method called after cloning on copying element
initComponents
Initialise default components.
Throws:
newComponent
Create / init new component.
public newComponent(string|null $name = null, string|null $type = null, array $options = [], array $attr = []): \Qubus\Form\FormBuilder\Element
Parameters:
| Parameter | Type | Description |
|---|---|---|
$name | string|null | Component name |
$type | string|null | Element type |
$options | array | Element options |
$attr | array | Element attr |
Throws:
getComponent
Get a component.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$name | string |
Throws:
getLabel
Get label component.
Throws:
getContainer
Get the container component.
Throws:
renderElement
Render to base HTML element.
- This method is abstract.
validateRequired
Validate if the control has a value if it's required.
validateMinMax
Validate if min and max for value.
validateLength
Validate the length of the value.
validatePattern
Validate the value of the control against a regex pattern.
validateMatch
Match value against another control.
validateUpload
Check if there were upload errors.
validateType
Validate if value matches the input type.
validateTypeColor
Validate the value for 'color' input type.
validateTypeNumber
Validate the value for 'number' input type.
validateTypeRange
Validate the value for 'range' input type.
validateTypeDate
Validate the value for 'date' input type.
validateTypeDatetime
Validate the value for 'datetime' input type.
validateTypeDatetimeLocal
Validate the value for 'datetime' input type.
validateTypeTime
Validate the value for 'datetime' input type.
validateTypeMonth
Validate the value for 'month' input type.
validateTypeWeek
Validate the value for 'week' input type.
validateTypeUrl
Validate the value for 'url' input type.
validateTypeEmail
Validate the value for 'email' input type.
getValidationScript
Get JavaScript for custom validation.
getValidationScriptRules
Get the rules to build up the validation script
generateValidationScript
Generate validation script
Parameters:
| Parameter | Type | Description |
|---|---|---|
$rules | array |
getValidationScriptMinlength
Get script to match the minimum length
getValidationScriptMatch
Get script to match other element
parseForScript
Parse a message, inserting values for placeholders for JavaScript.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$message | string |
resolvePlaceholderForScript
Get a value for a placeholder for JavaScript.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$var | string |
getDescription
Get the description of the element.
setValue
Set the value of the control.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$value | mixed |
Return Value:
$this
getValue
Get the value of the element.
setError
Set the error message.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$error | string | The error message |
getError
Get the error message (after validation).
getItems
Return list items