Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Extending LeftAndMain Help

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1250 Views
  • Gringo
    Avatar
    Community Member
    1 Post

    Extending LeftAndMain Help Link to this post

    Hi Guys,

    I've used the forums for a while for information and this is the first time I've had to post, I'm attempting to write a new LeftAndMain module for managing some data.

    What I'm trying to get tested and working is a complextablefield in a new tab in the right panel, I'm wanting to use it to manage data from a dataobject. I'm coming across the following error and after an hour or so of browsing I have no idea what I'm doing wrong.

    Fatal error: Call to a member function FormAction() on a non-object in H:\www\ijacca.co.uk\sapphire\forms\FormField.php on line 88

    Code

    <?php

    class JobsAdmin extends LeftAndMain {
    static $url_segment = 'jobs';
    static $menu_title = 'Jobs Administration';

    static $has_many = array (

    "Jobs"=>"Job",
    "Categorys"=>"Category",
    "RSSImports"=>"RSSImport"

    );

    /*
    public static $managed_models = array(
       'Jobs',
       'Category',
       'RSSImports'
    );*/

    function init() {
       parent::init();
    }

    function showForm() {

    /*$fields = parent::getCMSFields();

    $jobs = new HasManyComplexTableField($this, 'Jobs', 'Jobs', array("Title"=>"Job Title","Location"=>"Job Location","Approved"=>"Approved for viewing"));

    $fields->addFieldToTab("Root.Jobs",$jobs);

    return $fields;*/
    return new TabSet(
          $name = "TheTabSetName",
          new Tab(
             $title='Tab one',
             new HeaderField("A header"),
             new LiteralField("Lipsum","Lorem ipsum dolor sit amet enim.")
          ),
          new Tab(
             $title='Tab two',
             new HeaderField("A second header"),
             new LiteralField("Lipsum","Ipsum dolor sit amet enim."),
             new ComplexTableField(
                $controller = $this,
                $name = "Jobs",
                $sourceClass = "Job",
                $fieldList = array(
                   "Title"=>"Job Title",
                   "Location"=>"Job Location",
                   "Approved"=>"Approved for viewing"
                ),
                $callThisFunctionForPopupFields = "getCMSFields_forPopup",
                $sourceFilter = "",
                $sourceSort = ""
             )
          )
       );

    }

    }
    ?>

    --------------------------------------------------------

    <?php

    class Job extends DataObject {

       static $db = array (
          'RecuiterID'=>'Int',
          'Title'=>'Text',
          'Salery'=>'Int',
          'Sector'=>'Int',
          'Location'=>'Text',
          'JobType'=>'Int',
          'Description'=>'HTMLText',
          'Approved'=>'Boolean'
       );

       function getCMSFields_forPopup() {
          return new FieldSet(
             new TextField('Title', 'Job Title'),
             new TextareaField('Description', 'Job Description'),
             new CheckboxField("Approved", "Job Approved")
          );
       }

    }

    ?>

    ----------------------------------------------------

    I was going to use a has_many type until I noticed that the way I wanted things done I would have no has_one, so I though the complextablefield would be the way forward.

    Can anyone shed any light on my stupidity?

    Thanks in advance,

    Graham

    1250 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.