This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'gform_field_input', 'rw_change_checkbox_structure', 10, 5 ); | |
function rw_change_checkbox_structure($input, $field, $value, $lead_id, $form_id){ | |
$input_type = RGFormsModel::get_input_type($field); | |
if($input_type != "checkbox" || IS_ADMIN && RG_CURRENT_VIEW == "entry") | |
return $input; | |
$choices = ""; | |
if(is_array($field["choices"])){ | |
$choice_number = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// format: gform_column_input_content_FORMID_FIELDID_COLUMN | |
add_filter( 'gform_column_input_content_524_2_2', 'change_column_to_checkbox', 10, 6 ); | |
function change_column_to_checkbox( $input, $input_info, $field, $text, $value, $form_id ) { | |
$input_field_name = "input_{$field['id']}[]"; | |
$tabindex = GFCommon::get_tabindex(); | |
$new_input = "<input type='checkbox' {$tabindex} /><input type='hidden' name='{$input_field_name}' value=' ' />"; | |
return $new_input; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// format: gform_column_input_content_FORMID_FIELDID_COLUMN | |
add_filter( 'gform_column_input_content_524_2_2', 'change_column_to_checkbox', 10, 6 ); | |
function change_column_to_checkbox( $input, $input_info, $field, $text, $value, $form_id ) { | |
$input_field_name = "input_{$field['id']}[]"; | |
$tabindex = GFCommon::get_tabindex(); | |
$new_input = "<div class='ginput_container'><ul class='gfield_checkbox'>" . | |
"<li><input type='checkbox' {$tabindex} value='First Choice' /><label>First Choice</label></li>" . | |
"<li><input type='checkbox' {$tabindex} value='Second Choice' /><label>Second Choice</label></li>" . | |
"</ul><input type='hidden' name='{$input_field_name}' value='' /></div>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Trigger conditional logic by adding an onclick or onchange event to your custom field input or by using something like the following | |
jQuery('#input_8_1 :input').on('change', function () { | |
gf_apply_rules(8, [2, 3, 4]); | |
}); | |
*/ | |
add_filter( 'gform_pre_render', 'extend_conditional_logic_frontend' ); | |
function extend_conditional_logic_frontend( $form ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set options for chosen e.g disable search or set width to use percentage | |
add_action('gform_pre_render','set_chosen_options'); | |
function set_chosen_options($form){ | |
if(wp_script_is('gforms_chosen',$list='queue')){ | |
?> | |
<script> | |
gform.addFilter('gform_chosen_options','set_chosen_options_js'); | |
function set_chosen_options_js(options,element){ | |
//options.placeholder_text_single = 'Selectionner une Option'; // set default placeholder for blank first option | |
//options.search_contains = true; // search options for partial matches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// display form active/inactive status on the form settings view | |
add_filter('gform_form_settings', 'form_settings_status', 10, 2); | |
function form_settings_status($settings, $form){ | |
$form_info = RGFormsModel::get_form($form["id"]); | |
$status_val = intval($form_info->is_active); | |
$status = $status_val ? __('Active', 'gravityforms') : __('Inactive', 'gravityforms'); | |
$settings["Form Basics"]["form_status"] = "<tr><th><label>Form status</label></th><td><img class='gform_active_icon' src='".GFCommon::get_base_url()."/images/active{$status_val}.png' style='cursor:pointer;margin:5px 0 0 0;float:left;' alt='{$status}' title='{$status}' onclick='ToggleActive( this, {$form["id"]} );' /> <span class='gform_status' style='margin:3px 0 0 10px;float:left;' >{$status}</span></td></tr>"; | |
return $settings; | |
} | |
// add script to settings page to allow toggling of active/inactive status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('gform_enqueue_scripts_11', 'list_columns_mask_script'); | |
function list_columns_mask_script() { | |
wp_enqueue_script( 'gform_masked_input', array( 'jquery' ), false, true ); | |
} | |
add_filter('gform_register_init_scripts_11', 'list_columns_mask_init'); | |
function list_columns_mask_init( $form ) { | |
$init = ""; | |
/** | |
* Add a function call for each list field column you want to activate an input mask for | |
* $init .= "ListFieldMaskedInput( formId, fieldId, column, 'mask' );"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function ListFieldMaskedInput( formId, fieldId, column, mask ){ | |
jQuery( '.gfield_list_' + fieldId + '_cell' + column + ' input' ).mask( mask ); | |
jQuery( '#field_' + formId + '_' + fieldId ).on( 'click', '.add_list_item', function(){ | |
jQuery( '.gfield_list_' + fieldId + '_cell' + column + ' input' ).mask( mask ) | |
}); | |
} | |
ListFieldMaskedInput( 11, 2, 1, '9999' ); | |
/** | |
* Add a function call for each list field column you want to activate an input mask for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// log field validation errors | |
add_filter( 'gform_validation', 'log_validation_failure', 30 ); | |
function log_validation_failure( $validation_result ) { | |
$form = $validation_result['form']; | |
foreach ( $form['fields'] as &$field ) { | |
if ( $field['failed_validation'] ) | |
GFCommon::log_error( "form #{$form["id"]}: validate() - failed: {$field["label"]}({$field["id"]} - {$field["type"]}) - message: {$field["validation_message"]}" ); | |
} | |
return $validation_result; | |
} |
OlderNewer