Scaffold CMS form fields

@return FieldList
515765
public function getCMSFields()
    {
        $self = $this;
   
        $this->beforeUpdateCMSFields(function ($fields) use ($self) {
            $siteconfig = SiteConfig::current_site_config();

            $fields->removeByName("StartDate");
            $fields->removeByName("CustomerID");
            $fields->removeByName("EndDate");
            $fields->removeByName("Number");
            $fields->removeByName("Ref");
            $fields->removeByName("AccessKey");
            $fields->removeByName("Items");
            $fields->removeByName("Prefix");
            
            $fields->addFieldsToTab(
                "Root.Main",
                [
                    // Items field
                    ReadOnlyGridField::create(
                        "Items",
                        "",
                        $this->Items(),
                        $config = GridFieldConfig::create()
                            ->addComponents(
                                new GridFieldButtonRow('before'),
                                new GridFieldTitleHeader(),
                                new GridFieldEditableColumns(),
                                new GridFieldEditButton(),
                                new GridFieldDetailForm(),
                                new GridFieldDeleteAction(),
                                new AddLineItem()
                            )
                    ),

                    LiteralField::create(
                        "ItemsDivider",
                        '<div class="field form-group"></div>'
                    ),
                    
                    // Totals and settings
                    CompositeField::create(
                        CompositeField::create(
                            DateField::create("StartDate", _t("OrdersAdmin.Date", "Date")),
                            DateField::create("EndDate", _t("OrdersAdmin.Expires", "Expires")),
                            ReadonlyField::create("FullRef", "#"),
                            TextField::create("Ref", $this->fieldLabel("Ref"))
                        )->setName("OrdersDetailsInfo")
                        ->addExtraClass("col"),
                        CompositeField::create([])
                            ->setName("OrdersDetailsMisc")
                        ->addExtraClass("col"),
                        CompositeField::create(
                            ReadonlyField::create("SubTotalValue", _t("OrdersAdmin.SubTotal", "Sub Total"))
                                ->setValue($this->obj("SubTotal")->Nice()),
                            ReadonlyField::create("TaxValue", _t("OrdersAdmin.Tax", "Tax"))
                                ->setValue($this->obj("TaxTotal")->Nice()),
                            ReadonlyField::create("TotalValue", _t("OrdersAdmin.Total", "Total"))
                                ->setValue($this->obj("Total")->Nice())
                        )->setName("OrdersDetailsTotals")
                        ->addExtraClass("col")
                    )->setName("OrdersDetails")
                    ->addExtraClass("orders-details-field")
                    ->setColumnCount(2)
                    ->setFieldHolderTemplate("SilverCommerce\\OrdersAdmin\\Forms\\OrderDetailsField_holder")
                ]
            );

            $fields->addFieldsToTab(
                "Root.Customer",
                [
                    HasOneButtonField::create(
                        $this,
                        'Customer'
                    ),
                    TextField::create("Company"),
                    TextField::create("FirstName"),
                    TextField::create("Surname"),
                    TextField::create("Address1"),
                    TextField::create("Address2"),
                    TextField::create("City"),
                    TextField::create("County"),
                    TextField::create("PostCode"),
                    DropdownField::create(
                        'Country',
                        _t('OrdersAdmin.Country', 'Country'),
                        i18n::getData()->getCountries()
                    )->setEmptyString(""),
                    TextField::create("Email"),
                    TextField::create("PhoneNumber")
                ]
            );

            $fields->addFieldsToTab(
                "Root.Delivery",
                [
                    HeaderField::create(
                        "DeliveryDetailsHeader",
                        _t("Orders.DeliveryDetails", "Delivery Details")
                    ),
                    TextField::create("DeliveryCompany"),
                    TextField::create("DeliveryFirstName"),
                    TextField::create("DeliverySurname"),
                    TextField::create("DeliveryAddress1"),
                    TextField::create("DeliveryAddress2"),
                    TextField::create("DeliveryCity"),
                    TextField::create("DeliveryCounty"),
                    TextField::create("DeliveryPostCode"),
                    DropdownField::create(
                        'DeliveryCountry',
                        _t('OrdersAdmin.Country', 'Country'),
                        i18n::getData()->getCountries()
                    )->setEmptyString("")
                ]
            );

            $fields->addFieldToTab(
                "Root.History",
                VersionHistoryField::create(
                    "History",
                    _t("SilverCommerce\VersionHistoryField.History", "History"),
                    $self
                )->addExtraClass("stacked")
            );
            
            $root = $fields->findOrMakeTab("Root");

            if ($root) {
                $root->addextraClass('orders-root');
            }
        });
        
        return parent::getCMSFields();
    }
8869
protected function getFields() {
        if (!$this->_fields) {
            $this->_fields = new FieldList(
                $this->version,
                $this->solution['assistantSid'],
                $this->solution['sid']
            );
        }

        return $this->_fields;
    }
693199
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Insert Image Tab:
        
        $fields->insertAfter(
            Tab::create(
                'Image',
                $this->fieldLabel('Image')
            ),
            'Main'
        );
        
        // Create Image Fields:
        
        $fields->addFieldsToTab(
            'Root.Image',
            [
                FieldSection::create(
                    'LinkImage',
                    $this->fieldLabel('LinkImage'),
                    [
                        $image = UploadField::create(
                            'LinkImage',
                            $this->fieldLabel('LinkImageFile')
                        ),
                        ViewportsField::create(
                            'LinkImageWidth',
                            $this->fieldLabel('LinkImageWidth')
                        )->setUseTextInput(true),
                        ViewportsField::create(
                            'LinkImageHeight',
                            $this->fieldLabel('LinkImageHeight')
                        )->setUseTextInput(true),
                        CheckboxField::create(
                            'InlineVector',
                            $this->fieldLabel('InlineVector')
                        )
                    ]
                )
            ]
        );
        
        // Define Image Field:
        
        $image->setAllowedExtensions(['gif', 'jpg', 'jpeg', 'png', 'svg']);
        $image->setFolderName($this->getAssetFolder());
        
        // Answer Field Objects:
        
        return $fields;
    }
830950
public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fields->addFieldToTab(
            'Root.Blocks',
            GridField::create(
                'Blocks',
                'Blocks',
                $this->Blocks(),
                GridFieldConfig_MultiClassRecord::create(
                    $this->Blocks(),
                    singleton('BlockObject_Preset')->SubClassNames
                )
            )
        );
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
1060245
public function getCMSFields()
    {
        $linksGridConfig = GridFieldConfig_RelationEditor::create();
        if ($this->Links()->Count() > 0) {
            $linksGridConfig->addComponent(new GridFieldOrderableRows());
        }

        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            "Root.Main",
            array(
                TextareaField::create(
                    'Title'
                )->setRows(1),
                HTMLEditorField::create(
                    'Content'
                ),
                SortableUploadField::create(
                    'Images',
                    'Current Image(s)'
                ),
                GridField::create(
                    'Links',
                    'Links',
                    $this->Links(),
                    $linksGridConfig
                )
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
851492
public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $listGridConfig = GridFieldConfig_RelationEditor::create();
        if ($this->Items()->Count() > 0) {
            $listGridConfig->addComponent(new GridFieldOrderableRows());
        }

        $fields->addFieldToTab(
            'Root.Main',
            GridField::create(
                'Items',
                'List',
                $this->Items(),
                $listGridConfig
            )
        );

        $this->extend('updateCMSFields', $fields);

        return $fields;
    }
1229538
public function getCMSFields()
    {
        // Create Field Tab Set:
        
        $fields = FieldList::create(TabSet::create('Root'));
        
        // Create Main Tab:
        
        $fields->findOrMakeTab('Root.Main', $this->fieldLabel('Main'));
        
        // Create Class Field:
        
        if (!$this->isInDB()) {
            
            // Define Placeholder:
            
            $placeholder = _t(__CLASS__ . '.SELECTTYPETOCREATE', '(Select type to create)');
            
            // Create Dropdown Field:
            
            $classField = DropdownField::create(
                'ClassName',
                $this->fieldLabel('ClassName'),
                $this->getClassNameOptions()
            )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder);
            
        } else {
            
            // Create Read-Only Field:
            
            $classField = ReadonlyField::create(
                'Type',
                $this->fieldLabel('Type')
            );
            
        }
        
        // Add Class Field to Main Tab:
        
        $fields->addFieldToTab('Root.Main', $classField);
        
        // Apply Extensions:
        
        if ($this->isInDB()) {
            
            // Extend Field Objects:
            
            $this->extend('updateCMSFields', $fields);
            
        }
        
        // Answer Field Objects:
        
        return $fields;
    }
650166
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Define Placeholder:
        
        $placeholder = _t(__CLASS__ . '.DROPDOWNDEFAULT', '(default)');
        
        // Create Style Fields:
        
        $fields->addFieldsToTab(
            'Root.Style',
            [
                FieldSection::create(
                    'IconStyle',
                    $this->fieldLabel('IconStyle'),
                    [
                        DropdownField::create(
                            'IconSize',
                            $this->fieldLabel('IconSize'),
                            SharingIcon::singleton()->getIconSizeOptions()
                        ),
                        DropdownField::create(
                            'Placement',
                            $this->fieldLabel('Placement'),
                            SharingIcon::singleton()->getPlacementOptions()
                        )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder)
                    ]
                )
            ]
        );
        
        // Create Options Fields:
        
        $fields->addFieldsToTab(
            'Root.Options',
            [
                FieldSection::create(
                    'IconOptions',
                    $this->fieldLabel('IconOptions'),
                    [
                        CheckboxField::create(
                            'ShowTitles',
                            $this->fieldLabel('ShowTitles')
                        )
                    ]
                )
            ]
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
746603
public function getCMSFields()
    {
        // Create Field Tab Set:
        
        $fields = FieldList::create(TabSet::create('Root'));
        
        // Define Placeholder:
        
        $placeholder = _t(__CLASS__ . '.DROPDOWNSELECT', 'Select');
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                DropdownField::create(
                    'ColumnID',
                    $this->fieldLabel('ColumnID')
                )->setEmptyString(' ')->setAttribute('data-placeholder', $placeholder),
                PageMultiselectField::create(
                    'Pages',
                    $this->fieldLabel('Pages')
                ),
                ViewportsField::create(
                    'Span',
                    $this->fieldLabel('Span'),
                    $this->getColumnSpanOptions()
                ),
                CheckboxField::create(
                    'DoNotInherit',
                    $this->fieldLabel('DoNotInherit')
                )
            ]
        );
        
        // Extend Field Objects:
        
        $this->extend('updateCMSFields', $fields);
        
        // Answer Field Objects:
        
        return $fields;
    }
106157
public function getCMSFields() {
        $kapostBase=KapostAdmin::config()->kapost_base_url;
        if($kapostBase[strlen($kapostBase)-1]!='/') {
            $kapostBase.='/';
        }
        
        $fields=new FieldList(
                            new ReadonlyField('Title', $this->fieldLabel('Title')),
                            new ReadonlyField('Created', _t('KapostConversionHistory.CONVERSION_DATE', '_Conversion Date')),
                            new ReadonlyField('ConverterName', $this->fieldLabel('ConverterName')),
                            new ReadonlyField('KapostChangeTypeNice', $this->fieldLabel('KapostChangeType')),
                            new ReadonlyField('KapostAuthor', $this->fieldLabel('KapostAuthor')),
                            new ReadonlyField('DestinationTypeNice', $this->fieldLabel('DestinationType')),
                            $kapostRef=ReadonlyField::create(
                                                    'KapostRefID_linked',
                                                    $this->fieldLabel('KapostRefID'),
                                                    (!empty($kapostBase) ? '<a href="'.htmlentities($kapostBase.'posts/'.$this->KapostRefID).'" target="_blank">'.htmlentities($this->KapostRefID).'</a>':$this->KapostRefID)
                                                ),

                            $destination=ReadonlyField::create(
                                                            'Destination',
                                                            $this->fieldLabel('DestinationID'),
                                                            '<a href="'.htmlentities($this->getDestinationLink()).'" class="kapost-panel-link">'._t('KapostConversionHistory.CONVERTED_TO_OBJECT', '_View Destination Object').'</a>'
                                                        )
                        );
        
        
        $kapostRef->dontEscape=true;
        $destination->dontEscape=true;
        
        
        //Allow extensions to add/remove fields
        $this->extend('updateCMSFields', $fields);
        
        
        return $fields;
    }
996677
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                TextField::create(
                    'DeveloperName',
                    $this->fieldLabel('DeveloperName')
                ),
                PageDropdownField::create(
                    'DeveloperPageID',
                    $this->fieldLabel('DeveloperPageID')
                ),
                TextField::create(
                    'DeveloperURL',
                    $this->fieldLabel('DeveloperURL')
                )
            ]
        );
        
        // Create Options Fields:
        
        $fields->addFieldsToTab(
            'Root.Options',
            [
                FieldSection::create(
                    'DeveloperOptions',
                    $this->fieldLabel('DeveloperOptions'),
                    [
                        TextField::create(
                            'DeveloperText',
                            $this->fieldLabel('DeveloperText')
                        ),
                        CheckboxField::create(
                            'OpenLinkInNewTab',
                            $this->fieldLabel('OpenLinkInNewTab')
                        ),
                        CheckboxField::create(
                            'LinkDisabled',
                            $this->fieldLabel('LinkDisabled')
                        )
                    ]
                )
            ]
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
47359
public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            $fields->removeByName('ElementPromos');

            $config = GridFieldConfig_RecordViewer::create();
            $fields->addFieldToTab(
                'Root.Elements',
                GridField::create(
                    'ElementPromos',
                    'Elements',
                    $this->ElementPromos(),
                    $config
                )
            );

            $fields->dataFieldByName('Image')
                ->setFolderName('Uploads/Elements/Promos');
        });

        return parent::getCMSFields();
    }
630314
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Style Fields:
        
        $fields->addFieldToTab(
            'Root.Style',
            FieldSection::create(
                'ColumnStyle',
                $this->fieldLabel('Column'),
                [
                    ViewportsField::create(
                        'ColumnSpan',
                        $this->fieldLabel('Span'),
                        $this->getColumnSpanOptions()
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
184504
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->addFieldsToTab(
            'Root.Main',
            array(
                CurrencySelectField::create(
                    'CurrenciesAccepted',
                    _t('SchemaLocalBusiness.CURRENCIESACCEPTED', 'Currencies accepted')
                ),
                TextField::create(
                    'PaymentAccepted',
                    _t('SchemaLocalBusiness.PAYMENTACCEPTED', 'Payment accepted')
                ),
                TextField::create(
                    'PriceRange',
                    _t('SchemaLocalBusiness.PRICERANGE', 'Price range')
                ),
                TextField::create(
                    'OpenHours',
                    _t('SchemaLocalBusiness.OPENHOURS', 'Open hours')
                )
            )
        );
        return $fields;
    }
1252702
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Field Objects:
        
        $fields->fieldByName('Root.Options.TitleOptions')->push(
            CheckboxField::create(
                'HidePageTitle',
                _t(__CLASS__ . '.HIDETITLEOFPAGE', 'Hide title of page')
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
6136
public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        if (!$this->isAllowedChildren()) {
            return $fields;
        }
        $fields->addFieldsToTab(
            'Root.' . _t(__CLASS__ . '.CHILDREN', 'Children'),
            [
                GridField::create(
                    'Children',
                    _t(__CLASS__ . '.CHILDREN', 'Children'),
                    $this->Children(),
                    GridFieldConfig_RecordEditor::create()
                        ->addComponent(new GridFieldOrderableRows())
                )
            ]
        );

        return $fields;
    }
121918
public function getCMSFields()
    {
        /** @var FieldList $fields */
        $fields = parent::getCMSFields();

        // Get protector
        $protector = FormSpamProtectionExtension::get_protector();
        if (!$protector) {
            return $fields;
        }

        if ($this->Parent()->Fields() instanceof UnsavedRelationList) {
            return $fields;
        }

        // Each other text field in this group can be assigned a field mapping
        $mapGroup = FieldGroup::create()
            ->setTitle(_t(__CLASS__.'.SPAMFIELDMAPPING', 'Spam Field Mapping'))
            ->setName('SpamFieldMapping')
            ->setDescription(_t(
                __CLASS__.'.SPAMFIELDMAPPINGDESCRIPTION',
                'Select the form fields that correspond to any relevant spam protection identifiers'
            ));

        // Generate field specific settings
        $mappableFields = FormSpamProtectionExtension::config()->get('mappable_fields');
        $mappableFieldsMerged = array_combine($mappableFields, $mappableFields);
        foreach ($this->getCandidateFields() as $otherField) {
            $mapSetting = "Map-{$otherField->Name}";
            $fieldOption = DropdownField::create(
                'spammap-' . $mapSetting,
                $otherField->Title,
                $mappableFieldsMerged,
                $this->spamMapValue($mapSetting)
            )->setEmptyString('');
            $mapGroup->push($fieldOption);
        }
        $fields->addFieldToTab('Root.Main', $mapGroup);

        return $fields;
    }