Add support for multiple default values for a custom multiple field?
-
Hey,
I’m trying to develop a Custom Beaver module using the plugin documentation, and it works great. A big thank you for your work on this plugin.
I’ve noticed that at this point, there is no way to provide a multiple default value for a multiple field like this:
'field' => array( 'multiple' => true, 'type' => 'form', 'label' => esc_html__( 'Field', 'textdomain' ), 'form' => 'field', 'preview_text' => 'label', 'default' => array( array( 'label' => 'Field 1', 'key' => 'key1' ), array( 'label' => 'Field 2', 'key' => 'key2' ) ) )
Stil, there could be an easy way of doing this; If in the final class
FLBuilderModel
, in the static methodget_settings_form_defaults
instead of forcing the default value to be an explicit array like this:if ( $is_multiple && $supports_multiple ) { $defaults->$name = array( $default ); }
it would be a simple check like this:
if ( $is_multiple && $supports_multiple ) { $defaults->$name = is_array($default) ? $default : array( $default ); }
And this way we could easily initialize a multiple field with default values.
I would open a pull request or something but from what I could find there isn’t a GitHub repository or something where we could contribute?
Thanks,
Andrei
- The topic ‘Add support for multiple default values for a custom multiple field?’ is closed to new replies.