コード例 #1
0
 /**
  * Return the default button that should be clicked when another one isn't
  * available.
  *
  * @return FormAction
  */
 public function defaultAction()
 {
     if ($this->hasDefaultAction && $this->actions) {
         return $this->actions->first();
     }
     return null;
 }
コード例 #2
0
 /**
  * Test replacing a field with another one.
  */
 public function testReplaceField()
 {
     $fields = new FieldList();
     $tab = new Tab('Root');
     $fields->push($tab);
     /* A field gets added to the set */
     $fields->addFieldToTab('Root', new TextField('Country'));
     $this->assertSame($fields->dataFieldByName('Country'), $tab->fieldByName('Country'));
     $fields->replaceField('Country', new EmailField('Email'));
     $this->assertEquals(1, $tab->Fields()->Count());
     $fields = new FieldList();
     $fields->push(new TextField('Name', 'Your name'));
     $brack = new TextField('Name[Field]', 'Your name');
     $fields->replaceField('Name', $brack);
     $this->assertEquals(1, $fields->Count());
     $this->assertEquals('Name[Field]', $fields->first()->getName());
 }