Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » error saving content on HasManyComplexTableField

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 655 Views
  • erwanpia
    Avatar
    Community Member
    63 Posts

    error saving content on HasManyComplexTableField Link to this post

    Hi I'm getting the Error Saving Content on a page with a HasManyComplexTableField. I can't get to the error and have flushed DB and reviewed syntax 10 times, has anyone a hint on this ? Error gets away when I comment out the HasManyComplexTableField in ConfigPage ?

    Thanks guys

    =======UPDATE : ERROR FOUND : typo as usual - code below is now correct ====

    mysite/code/ConfigPage.php

    <?php

    class ConfigPage extends Page {
       
       static $icon = "tutorial/images/treeicons/news";
       static $db = array(

       );
       static $has_one = array( 'Photo1' => 'Image' );   
        static $has_many = array(
    'Customers' => 'Customer'
    );
    static $defaults = array( 'ShowInMenus' => false);

    function getCMSFields() {
    $fields = parent::getCMSFields();
       $fields->addFieldToTab('Root.Content.Main', new ImageField('Photo1'), 'Content');
       
       
        $tablefield = new HasManyComplexTableField(
    $this,
    'Customers',
    'Customer',
    array(
        'Name' => 'Name',
        'Description' => 'Description',
        'Url' => 'Url'
    ),
    'getCMSFields_forPopup'
    );
    $tablefield->setParentClass('ConfigPage');
    $tablefield->setAddTitle( 'Customer' );

    $fields->addFieldToTab( 'Root.Content.Customer', $tablefield );

       
       return $fields;
    }

    }

    class ConfigPage_Controller extends ContentController {
       function init() {
          parent::init();
       }

    }
    ?>

    mysite/code/Customer.php

    <?
    class Customer extends DataObject {

    static $db = array(
    'Name' => 'Text',
    'Description' => 'Text',
    'Url' => 'Text'
    );
    static $has_one = array(
    'MyConfig' => 'ConfigPage'
    );

    function getCMSFields_forPopup() {
    $fields = new FieldSet();
    $fields->push( new TextField( 'Name' ) );
    $fields->push( new TextField( 'Description' ) );
    $fields->push( new TextField( 'Url' ) );
    return $fields;
    }

    }?>

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