/** @test **/ public function testgetCMSFields() { $region = new Region(); $fields = $region->getCMSFields(); //Fiels array should not be empty $this->assertNotEmpty($fields); //Check total field $this->assertEquals(3, count($fields)); $this->assertCount(3, $fields); // Check basic field exists $this->assertNotEmpty($fields->dataFieldByName('Description')); $this->assertNotEmpty($fields->dataFieldByName('Title')); $this->assertNotEmpty($fields->dataFieldByName('Photo')); }
/** * Fields for CRUD of shipping regions * * @see DataObject::getCMSFields() */ public function getCMSFields() { // $fields = new FieldList( // $rootTab = new TabSet('Root', // $tabMain = new Tab('Region', // TextField::create('Code', _t('Region.CODE', 'Code')), // TextField::create('Title', _t('Region.TITLE', 'Title')), // DropdownField::create('CountryID', 'Country', Country_Shipping::get()->map()->toArray()) // ) // ) // ); // return $fields; $fields = parent::getCMSFields(); $fields->replaceField('CountryID', DropdownField::create('CountryID', 'Country', Country_Shipping::get()->map()->toArray())); $fields->removeByName('SortOrder'); $fields->removeByName('ShopConfigID'); return $fields; }
/** * Fields for CRUD of shipping regions * * @see DataObject::getCMSFields() */ function getCMSFields() { $fields = parent::getCMSFields(); $countryField = new DropdownField('CountryID', 'Country', Country::shipping_countries()); $fields->replaceField('CountryID', $countryField); return $fields; }