21301 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 860 Views |
-
Create more than one table in form

5 March 2010 at 9:27pm Last edited: 5 March 2010 9:30pm
Hello:
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:
US
Member 1...
Member 4...UK
Member 2...
Member 3...
I use this code:
-----------
$fields = new FieldSet(
new TabSet( 'Root',
new Tab(_t('MemberAdmin.DATA', 'Data'),
new LiteralField("Title", $title),
$idField,
new HeaderField ($title = $Country[0], $headingLevel = "2"),
$table[0],
new HeaderField ($title = $Country[1], $headingLevel = "2"),
$table[1],
new HeaderField ($title = $Country[2], $headingLevel = "2"),
$table[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?
Thanks
-
Re: Create more than one table in form

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),
$idField
);
$x = 0;
foreach($Countries as $Country) {
$fields->addFieldsToTab('Root', array(
new HeaderField("Header[$x]", $Country[$x]),
$table[$x];
));
$x++;
} -
Re: Create more than one table in form

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.
| 860 Views | ||
|
Page:
1
|
Go to Top |


