Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3812

validate dateformat OR set to null if empty

$
0
0

i have an editor instance which uses a datapicker and is working fine.
i would now like to give the user the option of clearing the date field and storing a null value.

    Field::inst( 'tblorders.GCCustomerChargedDate' )
        ->validator( 'Validate::dateFormat', array(
            'empty' => true,
            'format' => 'j M Y'
        ) )
        ->getFormatter( 'Format::datetime', array(
            'from' => 'Y-m-d',
            'to' =>   'j M Y'
        ) )
        ->setFormatter( 'Format::datetime', array(
            'from' => 'j M Y',
            'to' =>   'Y-m-d'
        ) ),

i have changed the validator to now allow an empty value, but the datetime field stores this as 0000-00-00, how can i force it t store empty value as null ?


Viewing all articles
Browse latest Browse all 3812

Trending Articles