e107sk.com

Date field

on Saturday 07 December 2019
comments: 0

Date field (with calender)

minimal settings:

'date_added' => array ( 'title' => 'Added', 'type' => 'datestamp', 'data' => 'int' ),
'date_modified' => array ( 'title' => 'Modified', 'type' => 'datestamp', 'data' => 'int' ),

Readonly:

'date_added' => array ( 'title' => 'Added', 'type' => 'datestamp', 'data' => 'int', 'readonly' => true ),
'date_modified' => array ( 'title' => 'Modified', 'type' => 'datestamp', 'data' => 'int', 'readonly' => true ),<span></span>

Readonly has 2 modes:
1 = read-only, but only when there is a value,
2 = read-only regardless.

Correct values:

public function beforeCreate($new_data,$old_data)
{ 
if(empty($new_data['date_added']))
{
$new_data['date_added'] = time();
}
$new_data['date_modified'] = time(); 
return $new_data;
}

public function beforeUpdate($new_data, $old_data, $id)
{
$new_data['date_modified'] = time(); 
return $new_data;
}

0 Comments

Other links

Follow us