Skip to content

DB_DataObject_FormBuilder tips, tricks and HOWTOs

gartner edited this page Feb 2, 2013 · 1 revision

Make nice selectors for date- and timefields

Make formBuilder treat the fields as text:

public $fb_elementTypeMap = array(
    'date' => 'text',
    'datetime' => 'text',
);

Attach a classname to the generated input-field:

public $fb_fieldAttributes = array(
    '<name_of_datefield>' => array('class' => 'isDateField'),
);

Include this piece of jQuery on the page, which will attach a datepicker to the element:

$('.isDateField').each(
    function(index, element)
    {
        $(this).datepicker({
            dateFormat: 'yy-mm-dd',
            minDate: null,
            showButtonPanel: true
        });
    }
);