Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
Add settings at the bottom of the field options in the sidebar.
Usage
add_action( 'frm_after_field_options', 'add_custom_field_setting' ); function add_custom_field_setting( $args )
Parameters
- $args (array)
- 'field' (array)
- 'display' (array) - A list of field options that should be shown for the current field.
- 'values' (array) - Details about the form.
Examples
Add custom setting to text field options
add_action( 'frm_after_field_options', 'add_custom_field_options_section' );
function add_custom_field_options_section( $args ) {
if ( 'text' !== $args['field']['type'] ) {
return;
}
$value = isset( $args['field']['custom_setting'] ) ? $args['field']['custom_setting'] : '';
?>
<div class="custom_field_settings">
<h3 class="frm-collapsed" aria-expanded="false" tabindex="0" role="button" aria-label="Custom settings" aria-controls="collapsible-section">
<?php
esc_html_e( 'Custom settings', 'text-domain' );
FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
?>
</h3>
<div class="frm_validation_box frm-collapse-me" role="group">
<p>
<label>
Custom setting
<input type="text" name="field_options[custom_setting_<?php echo intval( $args['field']['id'] ); ?>]" value="<?php echo esc_attr( $value ); ?>" />
</label>
</p>
</div>
</div>
<?php
}
add_filter( 'frm_default_field_options', 'add_custom_field_option', 10, 2 );
function add_custom_field_option( $options, $args ) {
if ( 'text' === $args['type'] ) {
$options['custom_setting'] = '';
}
return $options;
}