LLMS_Form_Templates::get_block( string $field_id, string $location, boolean $reusable )

Retrieve a block array for use in a template


Description Description

Returns a reusable block when $reusable is true or returns a regular block modified by legacy options for the given location when $reusable is false.


Top ↑

Parameters Parameters

$field_id

(string) (Required) The field's identifier as found in the block schema list returned by LLMS_Form_Templates::get_reusable_block_schema().

$location

(string) (Required) Form location. Accepts "checkout", "registration", or "account".

$reusable

(boolean) (Required) Whether or not a reusable block should be retrieved.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/forms/class-llms-form-templates.php

	public static function get_block( $field_id, $location, $reusable ) {

		if ( $reusable ) {
			return self::get_reusable_block( $field_id );
		}

		$legacy_opt = self::get_legacy_option( $field_id, $location );
		// Add a confirm group for email when confirmation is set or for password fields.
		$confirm    = ( ( 'email' === $field_id && 'yes' === $legacy_opt ) || 'password' === $field_id );
		$block_data = self::get_block_data( $field_id, $confirm );
		if ( 'hidden' === $legacy_opt ) {
			return array();
		}

		$block = $block_data['block'][0];

		if ( in_array( $legacy_opt, array( 'required', 'optional' ), true ) ) {
			$block = self::set_required_atts( $block, ( 'required' === $legacy_opt ) );
		}

		return $block;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.1.0 Method access set to public.
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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