Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » show dataObjects as tabs in fronend

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

Page: 1
Go to End
Author Topic: 247 Views
  • soolan
    Avatar
    Community Member
    11 Posts

    show dataObjects as tabs in fronend Link to this post

    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.

    247 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.