Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » GridFieldConfig::create | many_many | duplicate entries

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 282 Views
  • dacar
    Avatar
    Community Member
    168 Posts

    GridFieldConfig::create | many_many | duplicate entries Link to this post

    Hi,

    i am still working on an old problem. I have set up a gridfield for a many_many relation. Everything works fine, but if i want to "change relation status", the gridfield shows all items from page_mitarbeiter instead of mitarbeiter.

    http://stackoverflow.com/questions/19094863/multiple-rows-with-same-id-in-silverstripe-gridfield

       private static $many_many = array (
          'Mitarbeiter' => 'Mitarbeiter'
       );

       private static $many_many_extraFields = array(
          'Mitarbeiter' => array(
             'SortOrder' => "Int"
          )
       );

             $MitarbeiterFieldConfig = GridFieldConfig::create(200)->addComponents(
              new GridFieldToolbarHeader(),
              new GridFieldSortableHeader(),
              new GridFieldDataColumns(),
              new GridFieldDeleteAction('unlinkrelation'),
              new GridFieldSortableRows('SortOrder'),
              new GridFieldManyRelationHandler(), 'GridFieldPaginator'
              //new GridFieldPaginator(20)
             );

             $MitarbeiterField = new GridField("Mitarbeiter", "zuzuordnede Mitarbeiter", $this->Mitarbeiter(), $MitarbeiterFieldConfig);
             $fields->addFieldToTab('Root.Mitarbeiter', $MitarbeiterField);   

       public function Mitarbeiter() {
          $mitarbeiter = $this->getManyManyComponents('Mitarbeiter')->sort('SortOrder');
          return $mitarbeiter;
       }   

    Can anybody help?

  • Bereusei
    Avatar
    Community Member
    94 Posts

    Re: GridFieldConfig::create | many_many | duplicate entries Link to this post

    I don't know, what you mean with relation status. Did you mean from many_many to has_many?

  • dacar
    Avatar
    Community Member
    168 Posts

    Re: GridFieldConfig::create | many_many | duplicate entries Link to this post

    Hi Bereusei, thanks for spending your time. I have attached two pictures to show, what i mean.

    Greetings, Carsten.

  • Bereusei
    Avatar
    Community Member
    94 Posts

    Re: GridFieldConfig::create | many_many | duplicate entries Link to this post

    Sorry, I know very little about the sortable gridfield module. At least I canĀ“t see weird things in your code.

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