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
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;
}
/**
* Retrieve a field item from a list of fields by a key/value pair.
*
* @since 5.0.0
*
* @param array[] $fields List of LifterLMS Form Fields.
* @param string $key Setting key to search for.
* @param mixed $val Setting valued to search for.
* @param string $return Determine the return value. Use "field" to return the field settings
* array. Use "index" to return the index of the field in the $fields array.
* @return array|int|false `false` when the field isn't found in $fields, otherwise returns the field settings
* as an array when `$return` is "field". Otherwise returns the field's index as an int.
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. |