Field::add_error( string $code, string $message = '' )

Description #

Add error message to a field.

Parameters #

  • $code
    string (Required) Error code.
  • $message
    string (Optional) Error message. Default value: ''

Source #

File: lib/form/class-field.php

	public function add_error( $code, $message = '' ) {
		$this->errors[ $code ] = $message;
		$name                  = explode( '.', ap_to_dot_notation( $this->form_name ) );

		if ( is_array( $name ) ) {
			anspress()->get_form( $name[0] )->add_error( 'fields-error', __( 'Error found in fields, please check and re-submit', 'anspress-question-answer' ) );
		}
	}

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