Hi there,
Some time ago I used the multiform module for a client on SS2.4.7 I have just upgraded to SS3 and reworked the code for my multiform to comply. Works great except for I can't seem to figure out how to populate my datefield with todays date. I'm using the populateDefaults method.
Here is my new code:
CallEvent.php
class CallEvent extends DataObject{
static $db = array(
'CallerFirstName' => 'Text',
'CallerSurname' => 'Text',
'CallerRelationship' => 'Text',
'CallerPhone' => 'Text',
'CallerExt' => 'Text',
'CallerEmail' => 'Text',
'DateOfCall' => 'SS_Datetime',
'TimeOfCall' => 'Time',
'TotalNumberOfCalls' => 'Text',
'CallerStatusOther' => 'Text',
'PaperCopy' => 'Text',
'DetailsOfEnquiry' => 'HTMLText',
'ContactIn' => 'Text',
'ContactOut' => 'Text',
'TotalWebSearches' => 'Text',
'HubContact' => 'Text',
);
public function populateDefaults(){
parent::populateDefaults();
$this->DateOfCall = date('Y-m-d H:i:s', strtotime('now'));
}
...
$dateofcall = new DateField("DateOfCall", "Date of first call");
$dateofcall->setConfig('showcalendar', true);
$dateofcall->setConfig('dateformat', 'dd/MM/YYYY');
public function getFrontendFields($params = null){
$fields = $this->scaffoldFormFields(array(
'restrictFields' => array(
'CallerFirstName',
'CallerSurname',
'CallerRelationship',
'CallerPhone',
'CallerExt',
'CallerEmail',
'DateOfCall',
'TimeOfCall',
'TotalNumberOfCalls',
'CallerStatusOther',
'PaperCopy',
'DetailsOfEnquiry',
'ContactIn',
'ContactOut',
'TotalWebSearches',
'HubContact',
),
'fieldClasses' => array(
'CallerFirstName' => 'TextField',
'CallerSurname' => 'TextField',
'CallerRelationship' => 'TextField',
'CallerPhone' => 'TextField',
'CallerExt' => 'TextField',
'CallerEmail' => 'EmailField',
'DateOfCall' => 'DateField',
'TimeOfCall' => 'TimeField',
'TotalNumberOfCalls' => 'NumericField',
'CallerStatusOther' => 'TextField',
'PaperCopy' => 'CheckboxField',
'DetailsOfEnquiry' => 'HtmlEditorField',
'ContactIn' => 'NumericField',
'ContactOut' => 'NumericField',
'TotalWebSearches' => 'NumericField',
'HubContact' => 'TextField',
)
)
);
$fields->push( new TextField("CallerFirstName", "Callers first name"));
$fields->push( new TextField("CallerSurname", "Callers surname"));
$fields->push( new TextField("CallerRelationship", "Callers relationship to person"));
$fields->push( new TextField("CallerPhone", "Callers phone number"));
$fields->push( new TextField("CallerExt", "Callers extension number"));
$fields->push( new EmailField("CallerEmail", "Callers email address"));
$fields->push( $dateofcall );
...
From all the documentation and tutorials I have researched this looks as though it should work. Any help here is greatly appreciated. Thanks
Regards