LLMS_Forms_Dynamic_Fields::maybe_add_required_block_fields( array[] $blocks, string $location, array $args )

Maybe add the required email and password block to a form.


Parameters Parameters

$blocks

(array[]) (Required) Array of parsed WP_Block arrays.

$location

(string) (Required) The request form location ID.

$args

(array) (Required) Additional arguments passed to the short-circuit filter.


Top ↑

Return Return

(array[])


Top ↑

Source Source

File: includes/forms/class-llms-forms-dynamic-fields.php

	public function maybe_add_required_block_fields( $blocks, $location, $args ) {

		$fields_to_require = $this->get_required_fields_for_location( $location, $args );
		if ( empty( $fields_to_require ) ) {
			return $blocks;
		}

		foreach ( $fields_to_require as $field_id => $field_block_name ) {

			$block = $this->find_block( $field_id, $blocks );

			if ( ! empty( $block ) ) {
				// Fields in non checkout forms are always visible - see LLMS_Forms::get_form_html().
				$blocks = 'checkout' === $location ? $this->make_block_visible( $block[1], $blocks, $block[0] ) : $blocks;
				unset( $fields_to_require[ $field_id ] );
				if ( empty( $fields_to_require ) ) { // All the required blocks are present.
					return $blocks;
				}
			}
		}

		return $this->add_required_block_fields( $fields_to_require, $blocks, $location );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.4.1 Make sure added reusable blocks contain the actual required field, otherwise fall back on the dynamically generated ones.
5.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.