Jump to:

1999 Posts in 1408 Topics by 613 members

Form Questions

SilverStripe Forums » Form Questions » problems saving date data - CompositeDateField

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2069 Views
  • danzzz
    Avatar
    Community Member
    175 Posts

    problems saving date data - CompositeDateField Link to this post

    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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: problems saving date data - CompositeDateField Link to this post

    Where did you put that code snippet?

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: problems saving date data - CompositeDateField Link to this post

    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

    2069 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.