Gets the REST default value for a field.
Description
See also
Parameters
- $field
-
(Leaves_And_Love\Plugin_Lib\Fields\Field) (Required) Field to get the default value for.
Return
(array) Default value for the field.
Source
File: src/db-objects/forms/form-settings-page.php
protected function get_rest_default_for_field( $field ) { if ( null !== $field->default ) { return $field->default; } if ( $field->repeatable ) { return array(); } switch ( $field->slug ) { case 'group': case 'multiselect': case 'multibox': return array(); case 'checkbox': return false; case 'number': case 'range': $input_attrs = $field->input_attrs; if ( ! empty( $input_attrs['step'] ) && is_int( $input_attrs['step'] ) ) { if ( isset( $input_attrs['min'] ) && $input_attrs['min'] > 0 ) { return (int) $input_attrs['min']; } return 0; } if ( isset( $input_attrs['min'] ) && $input_attrs['min'] > 0.0 ) { return (float) $input_attrs['min']; } return 0.0; case 'media': if ( 'url' === $field->store ) { return ''; } return 0; } return ''; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |