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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

Custom FieldGroup ID


Go to End


2 Posts   2450 Views

Avatar
zenmonkey

Community Member, 545 Posts

2 September 2009 at 9:00am

Edited: 02/09/2009 9:01am

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)
											 )
      );

Avatar
ec8or

Community Member, 18 Posts

14 June 2011 at 4:17am

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)
            )
        );