Jump to:

3450 Posts in 1063 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Many many relationships question.

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

Page: 1
Go to End
Author Topic: 328 Views
  • T3nD4n
    Community Member
    16 Posts

    Many many relationships question. Link to this post

    First of all, sorry about my poor english.
    I'am new in silverstripe and i have a question about relationships.

    here are my classes:

    class Jugador extends DataObject {
       static $db = array(
             'Nombre' => 'Varchar',
             'Apellido' => 'Varchar',
       static $belongs_many_many = array(
             'Partido' => 'Partido'


    class Partido extends Page {

       public static $db = array(

       public static $many_many = array(
       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $config = GridFieldConfig_RelationEditor::create();
                'Nombre' => 'Nombre',
                'Apellido'=> 'Apellido'
                'Apellido'))->setResultsFormat('$Nombre - $Apellido');

          $jugadoresField = new GridField(
                'Jugadores', // Field name
                'Jugador', // Field title
          $fields->addFieldToTab('Root.Jugadores', $jugadoresField);
          $dateField = new DateField('Fecha');
          $dateField->setConfig('showcalendar', true);
          $fields->addFieldToTab('Root.Main', $dateField, 'Content');
          $fields->addFieldToTab("Root.Main", new TextField('Resultado'), 'Content');
          return $fields;

    so far i have a many many relation between "Partido" and "Jugador" (in english Match and players).
    if i add a "partido" i can link existing "jugador" to this new partido and works fine.
    the thing that i dont how to do is, that each player must have a diferent score on each "partido".
    and i dont know how to add that relation in the classes.

    any help will be appreciated.

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.