editing many many extra fields

Showing 1-7 of 7 messages
editing many many extra fields Nicolaas Thiemen Francken - Sunny Side Up 8/17/11 8:46 PM
does anyone know a nice solution for editing many many extra fields?

thank you

--
Nicolaas 
Re: [silverstripe-dev] editing many many extra fields Rodney Way 8/17/11 9:02 PM
Hi Nicolaas,

Andrew Short's itemsetfield module handles this nicely - https://github.com/ajshort/silverstripe-itemsetfield

Cheers,

Rodney.
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To post to this group, send email to silverst...@googlegroups.com.
To unsubscribe from this group, send email to silverstripe-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/silverstripe-dev?hl=en.
Re: [silverstripe-dev] editing many many extra fields Nicolaas Thiemen Francken - Sunny Side Up 8/17/11 9:26 PM
Rodney.... THANK YOU!
Re: [silverstripe-dev] editing many many extra fields Rodney Way 8/17/11 10:11 PM
Nah - thanks Andrew :)

On 18/08/11 14:26, Nicolaas Thiemen Francken - Sunny Side Up wrote:
Rodney.... THANK YOU!

--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To post to this group, send email to silverst...@googlegroups.com.
To unsubscribe from this group, send email to silverstripe-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/silverstripe-dev?hl=en.
Re: [silverstripe-dev] editing many many extra fields Nicolaas Thiemen Francken - Sunny Side Up 8/17/11 10:18 PM
Hi Rodney

I just installed this module and I cant get it to work....  I can select many many relationships, but I cant seem to edit (or view) any of the "extra" fields.

Any hints?

Nicolaas
Re: [silverstripe-dev] editing many many extra fields Rodney Way 8/17/11 10:47 PM
Check out the module docs (docs/en/index.md) - my guess is you'll be looking for the ManyManyPickerField...

Basically you'll need to update getCMSFields() on the DataObject declaring the many_many_extraFields - and add a function to the DataObject with the $belongs_many_many to return the actual picker field.

Here's an example from one of my sites; where the many_many is between AFLMatch & AFLPlayer. Essentially the example provides a 'Give votes to Player per Match' interface. Votes is the conceptual 'extra field' that goes into the join table.


HTH,

Rod.

   
   // AFLMatch

    public static $many_many = array(
        'Votes'        => 'AFLPlayer'
    );
   
    public static $many_many_extraFields = array(
        'Votes' => array('NumberOfVotes' => 'Int')
    );
   
    public function getCMSFields() { 
        $fields = parent::getCMSFields();
       
        $votesManyManyOptions = array(
            'ExtraFields'    => 'manyManyFieldSet',
        );

        $fields->addFieldsToTab('Root.Votes', array(
            new ManyManyPickerField(
                $this, 'Votes', 'Votes Awarded', array(
                    'ExtraFields'            => 'getCMSExtraFields',
                    'ShowPickedInSearch'     => false,
                    'ExtraFilter'            => '"TeamID" = ' . $this->HomeTeamID . ' OR "TeamID" = ' . $this->AwayTeamID,
            )),
        ));
       
        $rounds = DataObject::get('AFLRound')->map('ID', 'RoundNumber');
        $fields->addFieldToTab('Root.Main', new DropdownField('AFLRoundID', 'Round Number', $rounds, '', null, "None"));
       
        $teams = DataObject::get('AFLTeam')->map('ID', 'TeamName');
        $fields->addFieldToTab('Root.Main', new DropdownField('HomeTeamID', 'Home Team', $teams, '', null, "No Team"));
        $fields->addFieldToTab('Root.Main', new DropdownField('AwayTeamID', 'Away Team', $teams, '', null, "No Team"));
       
        return $fields;
    }

   

    // AFLPlayer

    public static $belongs_many_many = array(
        'Votes'            => 'AFLMatch'
    );

    /**
     * Used for ManyManyPickerField in AFLMatch
     * @return FieldSet
     */
    public function getCMSExtraFields() { 
        return new FieldSet(
            new NumericField('NumberOfVotes', 'Votes Awarded')
        );
    }
--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To post to this group, send email to silverst...@googlegroups.com.
To unsubscribe from this group, send email to silverstripe-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/silverstripe-dev?hl=en.
Re: [silverstripe-dev] editing many many extra fields Nicolaas Thiemen Francken - Sunny Side Up 8/17/11 11:09 PM
Rodney, that looks excellent! Thank you and thank you Andrew.