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
function listFieldDatepicker(formId, fieldId, column) { | |
var listField = '#field_' + formId + '_' + fieldId, | |
columnClass = '.gfield_list_' + fieldId + '_cell' + column + ' input'; | |
jQuery.datepicker.setDefaults({ | |
showOn: 'both', | |
buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png', | |
buttonImageOnly: true, | |
dateFormat: 'dd/mm/yy', | |
firstDay: 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
<script> | |
gform.addFilter( 'gform_calculation_result', function(result, formulaField, formId, calcObj ){ | |
if ( formulaField.field_id == "4" ){ | |
jQuery(".ginput_shipping_price").html(gformFormatMoney(result)).prev('input').val(gformFormatMoney(result)); | |
gformCalculateTotalPrice( formId ); | |
} | |
return result; | |
}); | |
</script> |
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
<input id="choice_1_3_other" type="text" value="" class="medium ginput_amount"> | |
<script> | |
jQuery('#choice_1_3_other').change(function() { | |
var $other = jQuery('#choice_1_3'); | |
var val = $other.val().split("|"); | |
$other.val( val[0] + '|' + gformToNumber(jQuery(this).val()) ); | |
gformCalculateTotalPrice(formId); | |
}); | |
</script> |
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; | |
} |
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
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
add_action( 'gform_pre_submission_8', 'uploads_log_pre_submission' ); | |
function uploads_log_pre_submission( $form ) { | |
foreach ( $form["fields"] as &$field ) { | |
if ( $field["type"] == "fileupload" ) { | |
$id = "input_".$field["id"]; | |
if ( $field["multipleFiles"] ) { | |
if ( empty( $_POST["gform_uploaded_files"] ) ) | |
continue; |
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
// enable input mask for form #95 list field #3 columns 1 and 3 | |
add_filter('gform_register_init_scripts_95', 'enable_list_input_mask'); | |
function enable_list_input_mask($form) { | |
$field_id = "3"; //set field id here | |
$col_id = array('1','3'); //set column id here | |
$mask = "9999"; //define mask here, examples at http://www.gravityhelp.com/documentation/page/Input_Mask | |
//that's it nothing more to configure | |
$c_sel = array(); | |
foreach($col_id as $c) { |
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 |