Form::find( string $value, boolean|array $fields = false, string $key = 'original_name' )
Description #
Find a field object.
Parameters #
- $valuestring (Required) Value for argument
$key. - $fieldsboolean | array (Optional) List of field where to search. Default value: false
- $keystring (Optional) Search field by which property of a field object. Default value: 'original_name'
Source #
File: lib/class-form.php
public function find( $value, $fields = false, $key = 'original_name' ) {
if ( false === $this->prepared ) {
$this->prepare();
}
$fields = false === $fields ? $this->fields : $fields;
$found = wp_filter_object_list( $fields, array( $key => $value ) );
if ( empty( $found ) ) {
foreach ( $fields as $field ) {
if ( ! empty( $field->child ) && ! empty( $field->child->fields ) ) {
$child_found = $this->find( $value, $field->child->fields );
if ( ! empty( $child_found ) ) {
$found = $child_found;
break;
}
}
}
}
return is_array( $found ) ? reset( $found ) : $found;
}
Expand full source code Collapse full source code View on GitHub: lib/class-form.php:313
Add your comment