Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

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

Datarelations Member - Event


Reply

811 Views

Avatar
snichme

13 December 2008 at 4:19am (Last edited: 13 December 2008 4:19am), Community Member, 2 Posts

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