class Form extends Link implements ArrayAccess

Form represents an HTML form.

Properties

protected DOMElement $node from AbstractUriElement
protected string $method from AbstractUriElement
protected string $currentUri from AbstractUriElement

Methods

__construct(DOMElement $node, string $currentUri, string|null $method = null, string $baseHref = null)

No description

getNode()

Gets the node associated with this link.

string
getMethod()

Gets the method associated with this link.

string
getUri()

Gets the URI associated with this link.

string
getRawUri()

Returns raw URI data.

string
canonicalizePath(string $path)

Returns the canonicalized URI path (see RFC 3986, section 5.2.4).

setNode(DOMElement $node)

Sets current \DOMElement instance.

getFormNode()

Gets the form node associated with this form.

$this
setValues(array $values)

Sets the value of the fields.

array
getValues()

Gets the field values.

array
getFiles()

Gets the file field values.

array
getPhpValues()

Gets the field values as PHP.

array
getPhpFiles()

Gets the file field values as PHP.

bool
has(string $name)

Returns true if the named field exists.

remove(string $name)

Removes a field from the form.

get(string $name)

Gets a named field.

set(FormField $field)

Sets a named field.

all()

Gets all fields.

bool
offsetExists(string $name)

Returns true if the named field exists.

offsetGet(string $name)

Gets the value of a field.

offsetSet(string $name, string|array $value)

Sets the value of a field.

offsetUnset(string $name)

Removes a field from the form.

disableValidation()

Disables validation.

Details

__construct(DOMElement $node, string $currentUri, string|null $method = null, string $baseHref = null)

Parameters

DOMElement $node A \DOMElement instance
string $currentUri The URI of the page where the link is embedded (or the base href)
string|null $method The method to use for the link (GET by default)
string $baseHref The URI of the used for relative links, but not for empty action

Exceptions

InvalidArgumentException if the node is not a link

DOMElement getNode()

Gets the node associated with this link.

Return Value

DOMElement A \DOMElement instance

string getMethod()

Gets the method associated with this link.

Return Value

string The method

string getUri()

Gets the URI associated with this link.

Return Value

string The URI

protected string getRawUri()

Returns raw URI data.

Return Value

string

protected string canonicalizePath(string $path)

Returns the canonicalized URI path (see RFC 3986, section 5.2.4).

Parameters

string $path URI path

Return Value

string

protected setNode(DOMElement $node)

Sets current \DOMElement instance.

Parameters

DOMElement $node A \DOMElement instance

Exceptions

LogicException If given node is not an anchor

DOMElement getFormNode()

Gets the form node associated with this form.

Return Value

DOMElement A \DOMElement instance

$this setValues(array $values)

Sets the value of the fields.

Parameters

array $values An array of field values

Return Value

$this

array getValues()

Gets the field values.

The returned array does not include file fields (see getFiles).

Return Value

array An array of field values

array getFiles()

Gets the file field values.

Return Value

array An array of file field values

array getPhpValues()

Gets the field values as PHP.

This method converts fields with the array notation (like foo[bar] to arrays) like PHP does.

Return Value

array An array of field values

array getPhpFiles()

Gets the file field values as PHP.

This method converts fields with the array notation (like foo[bar] to arrays) like PHP does. The returned array is consistent with the array for field values (see getPhpValues), rather than uploaded files found in $_FILES. For a compound file field foo[bar] it will create foo[bar][name], instead of foo[name][bar] which would be found in $_FILES.

Return Value

array An array of file field values

bool has(string $name)

Returns true if the named field exists.

Parameters

string $name The field name

Return Value

bool true if the field exists, false otherwise

remove(string $name)

Removes a field from the form.

Parameters

string $name The field name

FormField get(string $name)

Gets a named field.

Parameters

string $name The field name

Return Value

FormField The field instance

Exceptions

InvalidArgumentException When field is not present in this form

set(FormField $field)

Sets a named field.

Parameters

FormField $field

FormField[] all()

Gets all fields.

Return Value

FormField[]

bool offsetExists(string $name)

Returns true if the named field exists.

Parameters

string $name The field name

Return Value

bool true if the field exists, false otherwise

FormField offsetGet(string $name)

Gets the value of a field.

Parameters

string $name The field name

Return Value

FormField The associated Field instance

Exceptions

InvalidArgumentException if the field does not exist

offsetSet(string $name, string|array $value)

Sets the value of a field.

Parameters

string $name The field name
string|array $value The value of the field

Exceptions

InvalidArgumentException if the field does not exist

offsetUnset(string $name)

Removes a field from the form.

Parameters

string $name The field name

Form disableValidation()

Disables validation.

Return Value

Form