Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Datarelations Member - Event

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: 797 Views
  • snichme
    Avatar
    Community Member
    2 Posts

    Datarelations Member - Event Link to this post

    I've a problem with datarelations.

    On my page I've some Events that each Member can sing up to. The problem is that the member has to be able to choose what to drink and eat for each Event. I've tried to solve it using an extra dataobject called Participant like this

    EventPage
    many_many: Participant

    Participant
    Has_many: EventPage
    Has_one: Member

    Member
    has_one: Participant

    Each member can sing up to the event through a form on the event-page.
    The problem is that I dont know how to save the information in the correct way.

    File: EventPage

    $p = new Participant();
    if(isset($data['toDrink'])) {
       $p->Drink = $data['toDrink'];
    }
    if(isset($data['Vegetarian'])) {
       $p->Vegetarian = $data['Vegetarian'];
    }
    $p->Member = Member::CurrentUser();
    $e = $p->Events();
    $e->add($this);
    $p->write();
    $existingParticipants = $this->Participants();
    $existingParticipants->add($p);

    The fields
    - Member.ParticipantID
    - Participant.MemberID
    and the table
    - Participant_Events

    is still empty after the member has signup => The member doesnt get signed up..

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