LLMS_Forms::get_fields_settings_from_blocks( array $blocks )
Retrieve an array of LLMS_Form_Field settings from an array of blocks.
Parameters Parameters
- $blocks
-
(array) (Required) Array of WP Block arrays from
parse_blocks()
.
Return Return
(array)
Source Source
File: includes/forms/class-llms-forms.php
public function get_fields_settings_from_blocks( $blocks ) { $fields = array(); $blocks = $this->get_field_blocks( $blocks ); foreach ( $blocks as $block ) { $settings = $this->block_to_field_settings( $block, $blocks ); if ( empty( $settings ) ) { continue; } if ( 'hidden' === ( $settings['type'] ?? null ) && isset( $block['attrs']['field'] ) && 'checkbox' === $block['attrs']['field'] ) { // Convert hidden checkbox settings into multiple "checked" hidden fields. $settings['type'] = $block['attrs']['field']; $field = new LLMS_Form_Field( $settings ); $form_fields = $field->explode_options_to_fields( true ); foreach ( $form_fields as $form_field ) { $fields[] = $form_field->get_settings(); } } else { $field = new LLMS_Form_Field( $settings ); $fields[] = $field->get_settings(); } } return $fields; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.2.0 | Exploded hidden checkbox fields. |
5.1.0 | Pass the whole list of blocks to the $this->block_to_field_settings() method to better check whether a block is visible. |
5.0.0 | Introduced. |