Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » Custom FieldGroup ID

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

Page: 1
Go to End
Author Topic: 1630 Views
  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Custom FieldGroup ID Link to this post

    Is it possible to to set manually the FieldGroup ID (in a custom form) so its not a string of the Fields it contains?

    Here is my FieldSet

    $fields = new FieldSet(
                          new FieldGroup (
                                      new HeaderField('Personal Information', 3),
                                      new LabelField("explanation","To Set-up Your Account"),
                                      new TextField('FirstName', 'First Name'),
                                      new TextField('Surname','Last Name'),
                                      new EmailField('Email'),
                                      new ConfirmedPasswordField('Password')
                                      ),
                          new FieldGroup (
                                      new HeaderField('Company Information', 3),
                                      new LabelField("explanation","To Verfiy Eligibility"),
                                      new TextField('CompanyName','Company Name'),
                                      new DropdownField('CompanyType','Company Type',$companyTypeList),
                                      new TextField('CompanyURL','Company Website'),
                                      new TextField('HomePhone','Company Phone'),
                                      new TextField('Address','Address'),
                                      new TextField('AddressLine2','Address Line 2'),
                                      new TextField('City','City'),
                                      new TextField('State','State or Province'),
                                      new TextField('Country','Country'),
                                      new TextField('TaxIDNumber','TaxIDNumber'),
                                      new TextField('Distributor','Distributor'),
                                      new TextField('SalesRep','Sales Rep'),
                                      new TextareaField('Notes','Description'),
                                      new HiddenField('PageID', '', $this->ID)
                                      )
    );

  • beezer
    Avatar
    Community Member
    16 Posts

    Re: Custom FieldGroup ID Link to this post

    Old post but came up in Google when I tried to do the same thing so here goes:

    $billingAddress = new FieldGroup(
    new TextField("FullName", _t('AddressForm.ADDRESSNAME', 'Full Name'), _t('AddressForm.ADDRESSNAME')),
    new TextField("Address1", _t('AddressForm.ADDRESS1', 'Street'), _t('AddressForm.ADDRESS1')),
    new TextField("Address2", _t('AddressForm.ADDRESS2', 'Street 2'), _t('AddressForm.ADDRESS2')),
    new TextField("Address3", _t('AddressForm.ADDRESS3', 'Street 3'), _t('AddressForm.ADDRESS3')),
    new TextField("City", _t('AddressForm.CITY', 'City'), _t('AddressForm.CITY')),
    new TextField("Postcode", _t('AddressForm.POSTCODE', 'Postcode'), _t('AddressForm.Postcode')),
    new DropdownField('Country', _t('AddressForm.COUNTRY', 'Country'), $countries)
    );
    $billingAddress->setID('BillingAddress');

    $fields = new FieldSet(
    $billingAddress,
    new FieldGroup(
    new TextField("CardNumber", _t('AddressForm.CARDNUMBER', 'Card Number'), _t('AddressForm.CARDNUMBER')),
    new DropdownField('CardExpiryMonth', _t('AddressForm.CARDMONTH', 'Expiry Month'), $months),
    new DropdownField('CardExpiryYear', _t('AddressForm.CARDYEAR', 'Expiry Year'), $years)
    )
    );

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