Last active
November 2, 2022 17:35
-
-
Save geekontheroad/6d2a35405f9ba5bc09cf12e3b170e888 to your computer and use it in GitHub Desktop.
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
/** | |
* This snippet will add a datepicker to the list field of Gravity Forms. | |
* Just copy paste this snippet and complete the configuration at the bottom | |
* Also make sure that Jquery UI is loaded otherwise this won't work (<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>) | |
* | |
* @author Johan d'Hollander | |
* @link <https://geekontheroad.com> | |
**/ | |
jQuery(document).ready(function() { | |
/*add datepicker to list field*/ | |
function gotrListFieldDatepicker(formId, fieldId, column) { | |
let listField = '#field_' + formId + '_' + fieldId; | |
let columnClass = '.gfield_list_' + fieldId + '_cell' + column + ' input'; | |
jQuery(columnClass).datepicker({gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png', buttonImageOnly: true, dateFormat: 'dd/mm/yy', }); | |
jQuery(columnClass).css({'width': '80%', 'margin-right': '2px'}); | |
jQuery(listField).on('click', '.add_list_item', function () { | |
jQuery('.ui-datepicker-trigger').remove(); | |
jQuery(columnClass).removeClass('hasDatepicker').removeAttr('id').datepicker({gotoCurrent: true, prevText: '', showOn: 'both', buttonImage: '/wp-content/plugins/gravityforms/images/calendar.png', buttonImageOnly: true, dateFormat: 'dd/mm/yy', }); | |
}); | |
} | |
/** | |
* Configure here | |
* formid, field_id, list_column_id | |
**/ | |
gotrListFieldDatepicker(77, 1, 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment