Form::field_values( boolean|array $fields = false )

Description #

Get values from all fields.

Parameters #

  • $fields
    boolean | array (Optional) Child fields. Default value: false

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: lib/class-form.php

	private function field_values( $fields = false ) {
		$values = array();

		if ( false === $this->prepared ) {
			$this->prepare();
		}

		if ( false === $fields ) {
			$fields = $this->fields;
		}

		foreach ( (array) $fields as $field ) {
			$field->pre_get();
			$values[ $field->original_name ] = array( 'value' => $field->value() );
			if ( ! empty( $field->child ) && ! empty( $field->child->fields ) ) {
				$values[ $field->original_name ]['child'] = $this->field_values( $field->child->fields );
			}
		}

		return $values;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment