Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Create more than one table in form

Go to End

3 Posts   1385 Views


Community Member, 2 Posts

5 March 2010 at 9:27pm

Edited: 05/03/2010 9:30pm


Sorry by my bad english.

I newbie in SilverStripe, I learn step by step trough examples and documentation and follow the method: tried-error (or crash).

I have a problem: I need create a form with tables for grouped the members info according your Country.

For example:

Member 1...
Member 4...


Member 2...
Member 3


I use this code:


$fields = new FieldSet(
new TabSet( 'Root',
new Tab(_t('MemberAdmin.DATA', 'Data'),
new LiteralField("Title", $title),
new HeaderField ($title = $Country[0], $headingLevel = "2"),
new HeaderField ($title = $Country[1], $headingLevel = "2"),
new HeaderField ($title = $Country[2], $headingLevel = "2"),




$actions = new FieldSet();

$form = new Form($this, "EditForm", $fields, $actions);

return $form;


But the number of Countries (and consecuence of tables) is variable, I dont know previously if the array of Countries have 10, 20 or 30

Some solution?



Forum Moderator, 5523 Posts

7 March 2010 at 8:26pm

You can use a foreach loop to iterate over the array. Not sure where you are trying to do this, if its in the CMS not sure how you'll get the saving to work. Something like

$fields = new TabSet('Root', 
         new Tab(_t('MemberAdmin.DATA', 'Data'), 
         new LiteralField("Title", $title), 
$x = 0;
foreach($Countries as $Country) {
         $fields->addFieldsToTab('Root', array(
                  new HeaderField("Header[$x]", $Country[$x]),


Community Member, 2 Posts

10 March 2010 at 12:33am

Thanks by the help.

Now, I can show the tables with an array, but the problem is the tab.

I can't show the tables into a tab, I can show the tables without tab, but the background is gray (with a tab the background is white).

I think what my problem is with some thing: New FieldSet, SetTab, or like that this, but I dont search the solution for this simple problem.