Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Forms_Dynamic_Fields::add_required_block_fields( string[] $fields_to_require, array[] $blocks, string $location )

Add required block fields.

Parameters Parameters


(string[]) (Required) Array of field ids to require.


(array[]) (Required) Array of parsed WP_Block arrays to add required fields to.


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

Top ↑

Return Return


Top ↑

Source Source

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

	private function add_required_block_fields( $fields_to_require, $blocks, $location ) {

		$blocks_to_add = array();
		foreach ( $fields_to_require as $field_id => $block_to_add ) {

			// If a reusable block exists for the field, use it. Otherwise use a dynamically generated block from the template schema.
			$use_reusable = LLMS_Form_Templates::find_reusable_block( $block_to_add );
			$block        = LLMS_Form_Templates::get_block( $block_to_add, $location, $use_reusable );

			if ( $use_reusable ) {
				// Load reusable block.
				$_blocks = LLMS_Forms::instance()->load_reusable_blocks( array( $block ) );
				// The reusable block doesn't contain the needed block, use a dynamically generated block from the template schema.
				if ( empty( $_blocks ) || ! $this->find_block( $field_id, $_blocks ) ) {
					$_blocks = array( LLMS_Form_Templates::get_block( $block_to_add, $location, false ) );
				$block = $_blocks[0];

			$blocks_to_add[] = $block;

		// Make blocks to add visible.
		$blocks_to_add = 'checkout' === $location ? array_map( array( $this, 'make_all_visible' ), $blocks_to_add ) : $blocks_to_add;

		return array_merge(


Top ↑

Changelog Changelog

Version Description
5.4.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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