Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

problems saving date data - CompositeDateField


Reply


3 Posts   2180 Views

Avatar
danzzz

Community Member, 175 Posts

22 September 2009 at 12:43am

Edited: 22/09/2009 12:44am

hi again,

I'm using model admin and now can insert rows in the backend. I defined also this field:

"Geburtsdatum" => "Date"

im my $db array.

the backend form ask me for this field with a simple input field.

but in the frontend I replace the field:

$geburtsdatum = new CompositeDateField(
   'Geburtstag',
   'Geburtstag (Tag, Monat, Jahr)','','1910-2009'
);
      
$fields->replaceField('Geburtsdatum',$geburtsdatum);

so I have a better input format (3 dropdowns).

the problem now is, the date dont't loads ($form->loadDataFrom) into the 3 dropdown fields
and I also can't update the date from the frontend form.

what could be the problem here?

thx
daniel

Avatar
Sam

Administrator, 685 Posts

22 September 2009 at 9:34am

Where did you put that code snippet?

Avatar
danzzz

Community Member, 175 Posts

22 September 2009 at 6:37pm

hi sam,

I extend the Member class and put it in the getFrontendFields function:

public function getFrontendFields() {
      $fields = $this->scaffoldFormFields(array(
         'restrictFields' => array(
            'Anrede',
            'FirstName',
            'Surname',
            'Ort',
            'Email',
            'Geburtsdatum',
         ),
         'fieldClasses' => array(
            'Email' => 'EmailField',
         )
      ));
      
      $fields->changeFieldOrder(array(
         'Anrede',
         'FirstName',
         'Surname',
         'Ort',
         'Email',
         'Geburtsdatum'
      ));
      
      $geburtsdatum = new CompositeDateField(
         'Geburtstag',
         'Geburtstag (Tag, Monat, Jahr)','','1910-2009'
      );
      
      $fields->replaceField('Geburtsdatum',$geburtsdatum);
      
      return $fields;
   
   }

daniel