Skip to content

Textarea

Representation of a textarea element.


Methods

__construct

public __construct(array $options = [], array $attr = []): mixed

Parameters:

Parameter Type Description
$options array Element options
$attr array HTML attributes

Throws:


validate

Validate the textarea control.

public validate(): bool

renderElement

Render the textarea.

public renderElement(): string

Inherited methods

__construct

public __construct(array $options = [], array $attr = []): mixed

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

protected applyDeepDecorators(\Qubus\Form\FormBuilder\Group $parent): void

Parameters:

Parameter Type Description
$parent \Qubus\Form\FormBuilder\Group

getDecorators

Get all decorators

public getDecorators(): \Qubus\Form\FormBuilder\Decorator[]

convertCustomType

Convert custom (form specific) type to general factory type.

protected convertCustomType(string& $type, array& $options, array& $attr = []): void

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

public build(string $type, array $options = [], array $attr = []): \Qubus\Form\FormBuilder\Element

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

protected asComponentOf(\Qubus\Form\FormBuilder\Element $element): \Qubus\Form\FormBuilder\Element

Parameters:

Parameter Type Description
$element \Qubus\Form\FormBuilder\Element

Return Value:

$this


isComponent

Check if element is used as a component

public isComponent(): bool

setParent

Set parent element

protected setParent(\Qubus\Form\FormBuilder\Element $parent): \Qubus\Form\FormBuilder\Element

Parameters:

Parameter Type Description
$parent \Qubus\Form\FormBuilder\Element

Return Value:

$this

Throws:


getParent

Return parent element

public getParent(): \Qubus\Form\FormBuilder\Group|null

end

Get parent or element of which this is an component.

public end(): \Qubus\Form\FormBuilder\Element|\Qubus\Form\FormBuilder\Group|null

getId

Get element id.

public getId(): string

getName

Return the name of the control.

public getName(): bool|string|null

setAttr

Set HTML attribute(s).

final public setAttr(array|string $attr, mixed|null $value = null): \Qubus\Form\FormBuilder\Element
  • 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).

final public getAttr(string|null $attr = null): mixed

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

final public hasClass(string $class): bool
  • This method is final. Parameters:
Parameter Type Description
$class string

addClass

Add a class

final public addClass(array|string $class): \Qubus\Form\FormBuilder\Element
  • 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

public removeClass(array|string $class): \Qubus\Form\FormBuilder\Element

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

public setOption(array|string $option, mixed|null $value = null): \Qubus\Form\FormBuilder\Element

Parameters:

Parameter Type Description
$option array|string Option name or array with options
$value mixed|null

Return Value:

$this


getOption

Get an option.

public getOption(string $option): mixed

Parameters:

Parameter Type Description
$option string

getOptions

Get all options.

public getOptions(): array

Bubbles to combine options of parent/ancestors.


isValid

Validate the element.

final public isValid(): bool
  • This method is final.

validate

Standard validation for the element

protected validate(): bool

setContent

Set element content

public setContent(\Closure|string $content): $this

Parameters:

Parameter Type Description
$content \Closure|string Content as HTML

getContent

Get the element content

final public getContent(): string|null
  • This method is final.

renderContent

Render the element content

protected renderContent(): string|null

render

Render the element to HTML.

public render(): string

Throws:


toHTML

Render the element to HTML.

final public toHTML(): string
  • This method is final.

__toString

Render the element to HTML.

final public __toString(): string
  • This method is final.

parse

Parse a message, inserting values for placeholders.

public parse(string $message): string

Parameters:

Parameter Type Description
$message string

resolvePlaceholder

Get a value for a placeholder.

protected resolvePlaceholder(string $var): string

Parameters:

Parameter Type Description
$var string

convertTo

Convert an element to another type.

public convertTo(string $type): \Qubus\Form\FormBuilder\Element

Simply returns $this if element is already of correct type.

Parameters:

Parameter Type Description
$type string

__clone

Magic method called after cloning element

public __clone(): mixed

onClone

Method called after cloning on copying element

protected onClone(): void

initComponents

Initialise default components.

protected initComponents(): void

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.

public getComponent(string $name): \Qubus\Form\FormBuilder\Element|null

Parameters:

Parameter Type Description
$name string

Throws:


getLabel

Get label component.

public getLabel(): \Qubus\Form\FormBuilder\Element

Throws:


getContainer

Get the container component.

public getContainer(): \Qubus\Form\FormBuilder\Group

Throws:


renderElement

Render to base HTML element.

public renderElement(): string
  • This method is abstract.

validateRequired

Validate if the control has a value if it's required.

protected validateRequired(): bool

validateMinMax

Validate if min and max for value.

protected validateMinMax(): bool

validateLength

Validate the length of the value.

protected validateLength(): bool

validatePattern

Validate the value of the control against a regex pattern.

protected validatePattern(): bool

validateMatch

Match value against another control.

protected validateMatch(): bool

validateUpload

Check if there were upload errors.

protected validateUpload(): bool

validateType

Validate if value matches the input type.

protected validateType(): bool

validateTypeColor

Validate the value for 'color' input type.

protected validateTypeColor(): bool

validateTypeNumber

Validate the value for 'number' input type.

protected validateTypeNumber(): bool

validateTypeRange

Validate the value for 'range' input type.

protected validateTypeRange(): bool

validateTypeDate

Validate the value for 'date' input type.

protected validateTypeDate(): bool

validateTypeDatetime

Validate the value for 'datetime' input type.

protected validateTypeDatetime(): bool

validateTypeDatetimeLocal

Validate the value for 'datetime' input type.

protected validateTypeDatetimeLocal(): bool

validateTypeTime

Validate the value for 'datetime' input type.

protected validateTypeTime(): bool

validateTypeMonth

Validate the value for 'month' input type.

protected validateTypeMonth(): bool

validateTypeWeek

Validate the value for 'week' input type.

protected validateTypeWeek(): bool

validateTypeUrl

Validate the value for 'url' input type.

protected validateTypeUrl(): bool

validateTypeEmail

Validate the value for 'email' input type.

protected validateTypeEmail(): bool

getValidationScript

Get JavaScript for custom validation.

public getValidationScript(): string

getValidationScriptRules

Get the rules to build up the validation script

protected getValidationScriptRules(): array

generateValidationScript

Generate validation script

protected generateValidationScript(array $rules): string

Parameters:

Parameter Type Description
$rules array

getValidationScriptMinlength

Get script to match the minimum length

protected getValidationScriptMinlength(): string|null

getValidationScriptMatch

Get script to match other element

protected getValidationScriptMatch(): string|null

parseForScript

Parse a message, inserting values for placeholders for JavaScript.

public parseForScript(string $message): string

Parameters:

Parameter Type Description
$message string

resolvePlaceholderForScript

Get a value for a placeholder for JavaScript.

protected resolvePlaceholderForScript(string $var): string

Parameters:

Parameter Type Description
$var string

getDescription

Get the description of the element.

public getDescription(): string

setValue

Set the value of the element.

public setValue(mixed $value): mixed

Parameters:

Parameter Type Description
$value mixed

getValue

Get the value of the element.

public getValue(): mixed

setError

Set the error message.

public setError(string $error): void

Parameters:

Parameter Type Description
$error string The error message

getError

Get the error message (after validation).

public getError(): string|null