Jump to:

3461 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » getFrontendFields - ordering the fileds

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

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

    getFrontendFields - ordering the fileds Link to this post

    hi there,

    I have this function to generate a registration form:

    public function getFrontendFields() {
       $fields = $this->scaffoldFormFields(array(
          'restrictFields' => array(
             'Anrede',
             'FirstName',
             'Surname',
             'Email',
             'Geburtsdatum',
          ),
          'fieldClasses' => array(
             'Email' => 'EmailField',
          )
       ));
       
       return $fields;
       
    }

    so, first problem:
    on the page the ordering of the fields is not the same, the ordering is:

    FirstName,
    Surname,
    Email,
    Anrede (Salutation in German),
    Geburtsdatum (Birthday in German)

    how can I order the fields? for example the salutation should be on first place

    next question:

    how can I implement a CompositeDateField for my birthday field?
    If I would generate a normal form I would use:

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

    how can I implement this into my getFrontendFields Code?

    thanx

    Daniel

  • danzzz
    Avatar
    Community Member
    175 Posts

    Re: getFrontendFields - ordering the fileds Link to this post

    hi,

    I have the solution ... (thx 2 ajshort from silverstripe irc channel)

    field ordering:

    $fields->changeFieldOrder(array(
             'Anrede',
             'FirstName',
             'Surname',
             'Email',
             'Geburtsdatum'
          ));

    replaceing fields:

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

    daniel

    2531 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.