Form::add_field( string $path, mixed $val )

Description #

Add new field in form.

Parameters #

  • $path
    string (Required) Path of new array item. This must include field name at last.
  • $val
    mixed (Required) Value to set.

Source #

File: lib/class-form.php

	public function add_field( $path, $val ) {
		$path = is_string( $path ) ? explode( '.', $path ) : $path;
		$loc  = &$this->args['fields'];

		foreach ( (array) $path as $step ) {
			$loc = &$loc[ $step ]['fields'];
		}

		$loc['fields'] = $val;
	}

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