/**
 * PickADate Fields, aka the new date picker
 */
IGDATAPOOLFE.plugins.add('dateField', {
    form: null,
    initFields: function(form) {
	this.init(form);
    },
    init: function(form) {
	let $form = $(form);
	this.form = $form;
	$('.dp-pickadate', $form).each(function() {
	    var options = $(this).data('dateoptions');

	    //$(this).pickadate(options);
	    $(this).pickadate(options);
	    if($(this).data('submit')) {
		$(this ).on('change', function() {
		    $(this).parents('form').submit();
		});
	    }
	});
    }
});