public function getCMSFields()
 {
     $fields = new FieldList();
     $_REQUEST['entity_survey'] = 1;
     $fields->add(new TextField('EntityName', 'Entity Name (Without Spaces)'));
     $fields->add(new CheckboxField('Enabled', 'Is Enabled?'));
     $fields->add(new CheckboxField('UseTeamEdition', 'Allow Team Edition?'));
     $fields->add(new HiddenField('CreatedByID', 'CreatedByID', Member::currentUserID()));
     $fields->add(new HiddenField('ParentID', 'ParentID'));
     //steps
     if ($this->ID > 0) {
         $_REQUEST['survey_template_id'] = $this->ID;
         // steps
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('SurveyRegularStepTemplate' => 'Regular Step'));
         $config->addComponent($multi_class_selector);
         $config->addComponent(new GridFieldSortableRows('Order'));
         $gridField = new GridField('Steps', 'Steps', $this->Steps(), $config);
         $fields->add($gridField);
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $migration_mapping_types = array('NewDataModelSurveyMigrationMapping' => 'New Migration Mapping');
         $multi_class_selector->setClasses($migration_mapping_types);
         $config->addComponent($multi_class_selector);
         $gridField = new GridField('MigrationMappings', 'Migration Mappings', $this->MigrationMappings(), $config);
         $dataColumns = $config->getComponentByType('GridFieldDataColumns');
         $dataColumns->setDisplayFields(NewDataModelSurveyMigrationMapping::getDisplayFields());
         $fields->add($gridField);
     }
     return $fields;
 }
Пример #2
0
 public function getCMSFields()
 {
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $fields->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $start_date = new DatetimeField('StartDate', 'Start Date');
     $end_date = new DatetimeField('EndDate', 'End Date');
     $start_date->getDateField()->setConfig('showcalendar', true);
     $start_date->setConfig('dateformat', 'dd/MM/yyyy');
     $end_date->getDateField()->setConfig('showcalendar', true);
     $end_date->setConfig('dateformat', 'dd/MM/yyyy');
     $fields->addFieldToTab('Root.Main', $start_date);
     $fields->addFieldToTab('Root.Main', $end_date);
     $fields->addFieldToTab('Root.Main', new CheckboxField('Enabled', 'Is Enabled'));
     $fields->addFieldToTab('Root.Main', new HiddenField('CreatedByID', 'CreatedByID', Member::currentUserID()));
     //steps
     if ($this->ID > 0) {
         $_REQUEST['survey_template_id'] = $this->ID;
         // steps
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $step_types = array('SurveyRegularStepTemplate' => 'Regular Step', 'SurveyDynamicEntityStepTemplate' => 'Entities Holder Step');
         $count = $this->Steps()->filter('ClassName', 'SurveyThankYouStepTemplate')->count();
         if (intval($count) === 0) {
             $step_types['SurveyThankYouStepTemplate'] = 'Thank You (Final)';
         }
         $multi_class_selector->setClasses($step_types);
         $config->addComponent($multi_class_selector);
         $config->addComponent($sort = new GridFieldSortableRows('Order'));
         $gridField = new GridField('Steps', 'Steps', $this->Steps(), $config);
         $fields->addFieldToTab('Root.Main', $gridField);
         //entities
         $config = GridFieldConfig_RecordEditor::create();
         $gridField = new GridField('EntitySurveys', 'Entities', $this->EntitySurveys(), $config);
         $fields->addFieldToTab('Root.Main', $gridField);
         // instances
         $config = GridFieldConfig_RecordEditor::create(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $gridField = new GridField('Instances', 'Instances', $this->Instances(), $config);
         $fields->addFieldToTab('Root.Surveys', $gridField);
         //migration Mappings
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $migration_mapping_types = array('NewDataModelSurveyMigrationMapping' => 'New Migration Mapping');
         $multi_class_selector->setClasses($migration_mapping_types);
         $config->addComponent($multi_class_selector);
         $gridField = new GridField('MigrationMappings', 'Migration Mappings', $this->MigrationMappings(), $config);
         $dataColumns = $config->getComponentByType('GridFieldDataColumns');
         $migration = $this->MigrationMappings()->first();
         $dataColumns->setDisplayFields(!is_null($migration) && $migration->ClassName === 'OldDataModelSurveyMigrationMapping' ? OldDataModelSurveyMigrationMapping::getDisplayFields() : NewDataModelSurveyMigrationMapping::getDisplayFields());
         $fields->addFieldToTab('Root.Main', $gridField);
     }
     return $fields;
 }