public function updateCMSFields(FieldSet $fields)
 {
     $service = singleton('WorkflowService');
     if ($effective = $service->getDefinitionFor($this->owner)) {
         $effectiveTitle = $effective->Title;
     } else {
         $effectiveTitle = _t('WorkflowApplicable.NONE', '(none)');
     }
     $allDefinitions = array(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
     if ($definitions = $service->getDefinitions()) {
         $allDefinitions += $definitions->map();
     }
     $tab = $fields->fieldByName('Root') ? 'Root.Workflow' : 'BottomRoot.Workflow';
     $applyWorkflowField = null;
     $fields->addFieldToTab($tab, new HeaderField('AppliedWorkflowHeader', _t('WorkflowApplicable.APPLIEDWORKFLOW', 'Applied Workflow')));
     if (Permission::check('APPLY_WORKFLOW')) {
         $fields->addFieldToTab($tab, new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'), $allDefinitions));
     }
     $fields->addFieldToTab($tab, new ReadonlyField('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $effectiveTitle));
     $fields->addFieldToTab($tab, new HeaderField('WorkflowLogHeader', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log')));
     $fields->addFieldToTab($tab, $logTable = new ComplexTableField($this->owner, 'WorkflowLog', 'WorkflowInstance', null, 'getActionsSummaryFields', sprintf('"TargetClass" = \'%s\' AND "TargetID" = %d', $this->owner->class, $this->owner->ID)));
     $logTable->setRelationAutoSetting(false);
     $logTable->setPermissions(array('show'));
     $logTable->setPopupSize(760, 420);
 }
 /**
  * Return the forms fields for the template, but filter the fields for 
  * a particular 'set' of fields.
  * 
  * @return FieldSet The form fields
  */
 function Fields($set = null)
 {
     if ($set) {
         $fields = new FieldSet();
         //TODO fix this, have to disable security token for now @see CheckoutPage::OrderForm()
         foreach ($this->getExtraFields() as $field) {
             if (!$this->extraFieldsSet->fieldByName($field->Name())) {
                 $this->extraFieldsSet->push($field);
                 $fields->push($field);
             }
         }
         if ($set && isset($this->groupedFields[$set])) {
             if (is_array($this->groupedFields[$set])) {
                 foreach ($this->groupedFields[$set] as $field) {
                     $fields->push($field);
                 }
             } else {
                 $fields->push($this->groupedFields[$set]);
             }
         }
         return $fields;
     } else {
         return parent::Fields();
     }
     //For the validator to get fields
 }
 /**
  * Fields to display this {@link Payment} in the CMS, removed some of the 
  * unnecessary fields.
  * 
  * @see DataObjectDecorator::updateCMSFields()
  * @return FieldSet
  */
 function updateCMSFields(FieldSet &$fields)
 {
     $toBeRemoved = array('IP', 'ProxyIP', 'PaidForID', 'PaidForClass', 'PaymentDate', 'ExceptionError', 'Token', 'PayerID', 'RecurringPaymentID');
     foreach ($toBeRemoved as $field) {
         $fields->removeByName($field);
     }
     $toBeReadOnly = array('TransactionID', 'PaidByID');
     foreach ($toBeReadOnly as $field) {
         if ($fields->fieldByName($field)) {
             $fields->makeFieldReadonly($field);
         }
     }
     return $fields;
 }
 function testAddingFieldToATabWithTheSameNameAsTheField()
 {
     $fieldSet = new FieldSet($root = new TabSet("Root", $main = new Tab("Main", $a = new TextField("A"))));
     /* If you have a tab with the same name as the field, then technically it's a duplicate. However, it's allowed because
     		tab isn't a data field.  Only duplicate data fields are problematic */
     $fieldSet->addFieldToTab("Root.MyName", $myName = new TextField("MyName"));
     $this->assertNotNull($fieldSet->fieldByName('Root')->fieldByName('MyName'));
     $this->assertSame($myName, $fieldSet->fieldByName('Root')->fieldByName('MyName')->Fields()->First());
 }
 /**
  * Note: Doesn't call {@link FormField->setForm()}
  * on the returned {@link HiddenField}, you'll need to take
  * care of this yourself.
  * 
  * @param FieldSet $fieldset
  * @return HiddenField|false
  */
 function updateFieldSet(&$fieldset)
 {
     if (!$fieldset->fieldByName($this->getName())) {
         $field = new HiddenField($this->getName(), null, $this->getValue());
         $fieldset->push($field);
         return $field;
     } else {
         return false;
     }
 }
Example #6
0
 public function fieldByName($name)
 {
     return $this->children->fieldByName($name);
 }