class Form extends Link implements ArrayAccess
Form represents an HTML form.
__construct(DOMElement $node, string $currentUri, string $method = null, string $baseHref = null) | ||
DOMElement | 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. | |
string | getUri() Gets the URI of the form. | |
string | getMethod() Gets the form method. | |
bool | has(string $name) Returns true if the named field exists. | |
remove(string $name) Removes a field from the form. | ||
FormField | get(string $name) Gets a named field. | |
set(FormField $field) Sets a named field. | ||
FormField[] | all() Gets all fields. | |
bool | offsetExists(string $name) Returns true if the named field exists. | |
FormField | 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. | ||
Form | disableValidation() Disables validation. |
DOMElement | $node | A \DOMElement instance |
string | $currentUri | The URI of the page where the form is embedded |
string | $method | The method to use for the link (if null, it defaults to the method defined by the form) |
string | $baseHref | The URI of the |
LogicException | if the node is not a button inside a form tag |
Gets the form node associated with this form.
DOMElement | A \DOMElement instance |
Sets the value of the fields.
array | $values | An array of field values |
$this |
Gets the field values.
The returned array does not include file fields (see getFiles).
array | An array of field values |
Gets the file field values.
array | An array of file field values |
Gets the field values as PHP.
This method converts fields with the array notation (like foo[bar] to arrays) like PHP does.
array | An array of field values |
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.
array | An array of file field values |
Gets the URI of the form.
The returned URI is not the same as the form "action" attribute. This method merges the value if the method is GET to mimics browser behavior.
string | The URI |
Gets the form method.
If no method is defined in the form, GET is returned.
string | The method |
Returns true if the named field exists.
string | $name | The field name |
bool | true if the field exists, false otherwise |
Removes a field from the form.
string | $name | The field name |
Gets a named field.
string | $name | The field name |
FormField | The field instance |
InvalidArgumentException | When field is not present in this form |
Sets a named field.
FormField | $field |
Gets all fields.
FormField[] |
Returns true if the named field exists.
string | $name | The field name |
bool | true if the field exists, false otherwise |
Gets the value of a field.
string | $name | The field name |
FormField | The associated Field instance |
InvalidArgumentException | if the field does not exist |
Sets the value of a field.
string | $name | The field name |
string|array | $value | The value of the field |
InvalidArgumentException | if the field does not exist |
Removes a field from the form.
string | $name | The field name |
Disables validation.
Form |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/4.0/Symfony/Component/DomCrawler/Form.html