View more context

 

Brad.EH

So that gives me an error saying Fatal error: FieldList::addFieldToTab() Tried to add a tab to object 'SilverStripe\Forms\FieldList' - 'Hero' didn't exist. in /var/www/html/vendor/silverstripe/framework/src/Forms/FieldList.php on line 473

Brad.EH
  1. $fields->insertBefore(new Tab('Root.Hero', 'Hero'), 'Main');
  2.  
  3. $fields->addFieldToTab('Root.Hero', TextField::create('HeroSubtitle','Subtitle'));
nightjarnz

@Brad.EH I think this is expected - you're adding a tab to "Main", then adding a new tab to Root.Main - which results in two Tabs named Main. What you're looking for on the first line is new TabSet (although ideally you'd use TabSet::create)

nightjarnz

Tabs belong to TabSets TabSets can contain Tabs or more TabSets, Tabs contain Fields.

nightjarnz

It's not quite that cut and dry though, since Tabs and TabSets both extend from FormField... it gets very esoteric and relies on developer convention and self management.

Nathan Cox

$fields->insertBefore(Tab::create('Hero'), 'Main');

Brad.EH
  1. $tab = new Tab('Root.Hero', 'Hero');
  2. $tab->push(TextField::create('HeroSubtitle','Subtitle'));
Nathan Cox

Odd

  1. $fields->insertBefore(Tab::create('Hero'), 'Main');
  2. $fields->addFieldToTab('Root.Hero', TextField::create('TestField ','Test me'));

Works fine for me

Nathan Cox
Files: Requires logging in with Slack to view/download
wizards.jpg