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.

Data Model Questions

show dataObjects as tabs in fronend


Reply

316 Views

Avatar
soolan

1 March 2013 at 1:50pm Community Member, 11 Posts

Hello,
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 Product.ss file:
<div id="myform">
<h2>my form</h2>
$myForm
</div>
<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.