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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

show dataObjects as tabs in fronend

Go to End



Community Member, 11 Posts

1 March 2013 at 1:50pm

I have two data objects: one for Products, one for Features.

I want to show them in front-end as two tabs in a Tabset. So I created a Form in my controller class

class Product_Controller extends Page_Controller{
public static $allowed_actions = array('myForm');

public function myForm() {
// Create fields
$fields = new FieldList(
new TabSet(
$name = "TheTabSetName",
new Tab(
$title='Tab one',
new HeaderField("A header"),
new LiteralField("info from dataobject1.") // to keep it simple I replace the code with some place-holder texts
new Tab(
$title='Tab two',
new HeaderField("A second header"),
new LiteralField("info from dataobject2.")

return new Form($this, 'myForm', $fields);

And here it is my file:
<div id="myform">
<h2>my form</h2>
<div class="Content">

But it doesn't show the form.

May I ask you what I'm doing wrong here?

The other question is should I use forms to show tabbed view in frontend?

Thank you.