acf_field_icon_picker::validate_valuepublicACF 6.3

Validates the field value before it is saved into the database.

Метод класса: acf_field_icon_picker{}

Хуков нет.

Возвращает

true|false. true If the value is valid, false if not.

Использование

$acf_field_icon_picker = new acf_field_icon_picker();
$acf_field_icon_picker->validate_value( $valid, $value, $field, $input );
$valid(int) (обязательный)
The current validation status.
$value(разное) (обязательный)
The value of the field.
$field(массив) (обязательный)
The field array holding all the field options.
$input(строка) (обязательный)
The corresponding input name for $_POST value.

Список изменений

С версии 6.3 Введена.

Код acf_field_icon_picker::validate_value() ACF 6.4.2

public function validate_value( $valid, $value, $field, $input ) {
	// If the value is empty, return true. You're allowed to save nothing.
	if ( empty( $value ) && empty( $field['required'] ) ) {
		return true;
	}

	// If the value is not an array, return $valid status.
	if ( ! is_array( $value ) ) {
		return $valid;
	}

	// If the value is an array, but the type is not set, fail validation.
	if ( ! isset( $value['type'] ) ) {
		return __( 'Icon picker requires an icon type.', 'acf' );
	}

	// If the value is an array, but the value is not set, fail validation.
	if ( ! isset( $value['value'] ) ) {
		return __( 'Icon picker requires a value.', 'acf' );
	}

	return true;
}