Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » ManyManyComplexTableField into a DataObject

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

Page: 1
Go to End
Author Topic: 1708 Views
  • ttyl
    Avatar
    Community Member
    114 Posts

    ManyManyComplexTableField into a DataObject Link to this post

    I've gotten some strange behavior trying to put a ManyManyComplexTableField into a DataObject. When I put in the following code and try to create a new entry I just get a blank box and my PHP logs say "Call to a member function MyUnits() on a non-object in /Applications/MAMP/htdocs/ss_clean/sapphire/forms/HasManyComplexTableField.php" - but when I try to edit an existing record I get the table I want but nothing gets saved when I updated even though it says it went through.

    class Person extends DataObject {

    static $db = array(
    'FirstName' => 'Text',
    'LastName' => 'Text',
    'Role' => 'Text',
    'Email' => 'Text'
    );

    static $has_one = array(
    'HeadShot' => 'Image',
    );

    static $many_many = array (
    'MyUnits' => 'Unit'
    );

    function getCMSFields_forPopup() {
    $fields = new FieldSet();

    $fields->push( new TextField( 'FirstName', 'First Name' ) );
    $fields->push( new TextField( 'LastName', 'Last Name' ) );
    $fields->push( new TextField( 'Email' ) );

    $fields->push(new DropdownField('Role', 'Role', array(
    'Alumni' => 'Alumni',
    'Faculty' => 'Faculty',
    'Staff' => 'Staff',
    'Student' =>'Student'
    )), 'Content'
    );

    $fields->push(new ImageField('HeadShot'));

    $fields->push(new ManyManyComplexTableField(
    $this,
    'MyUnits',
    'Unit',
    array('Name' => 'Unit Name')
    ));

    return $fields;
    }

    ---

    so when I take out the "push->(new ManyMany..." I can create a new record, but when I put it back in it only shows on edit - but nothing gets saved. I'm not sure if I'm explaining this clearly as I'm honestly confused...

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: ManyManyComplexTableField into a DataObject Link to this post

    I just added a record to my table manually and when I edit the 'person' record it comes up as checked in my manymnaycomplextablefield - but still nothing on saving an update. so I think the problem can be narrowed down to getting updates commited and creating new records.

  • cake
    Avatar
    Community Member
    19 Posts

    Re: ManyManyComplexTableField into a DataObject Link to this post

    Hi!
    Did you find a solution for that? I've got a similar issue. Nothing is saved, checked or updated. I'm on SS 2.3.6!

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: ManyManyComplexTableField into a DataObject Link to this post

    oh man, that was a while ago. I think I just ended up figuring out a work-around.

    sorry I can't be of more help!

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