Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
To convert a list field column to use a checkbox add the php excluding the first line to your theme functions.php file. The JavaScript can be placed between script tags in a HTML field on the form.
<?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;
}
jQuery( '.ginput_list' ).on( 'click', 'input[type=checkbox]', function() {
elem = jQuery(this);
elem.next('input').val(elem.is(':checked') ? 'Yes' : ' ');
}).on( 'click', '.add_list_item', function() {
jQuery(this).parent().parent().next()
.find('input[type=checkbox]').prop('checked', false)
.next('input').val(' ');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.