Hey guys,
I´ve created an DOM (Workshoptraining) in an DOM (Workshop) (thanks to UncleCheese). Imagine a Workshop, that occure on a particular day.
That workshop has many trainingsessions (on 11.00, on 12.00, ...)
Now I´ve created an form with two DropDownFields, where users can registrate.
With the DropDownFields they can select a Workshop (on monday for example) and then they must select a trainingsession (11:00) for this particular workshop.
I figured out, how I can call each DataObject to list the elements in the DropDownFields, but instead of getting only the sessions for the particular workshop, I get all sessions from all workshops. How can I filter my list in the second DropDownField, so that I get only the sessions from the workshop, that I´ve selected before?
//my Workshop class extends DataObject
...
public function getCMSFields()
{
return new FieldSet(
new DateField('Date'),
new TextField('Workshopname'),
new TextField('Coach'),
new DataObjectManager(
$this,
'Workshoptrainingsessions',
'Workshoptraining',
array('Time' => 'Time', 'Type' => 'Type')
)
)
}
//my Workshoptraining class extends DataObject
...
//Fields for the DOM Popup
public function getCMSFields()
{
return new FieldSet(
new TimeField('Zeit'),
new TextField('Type')
);
}
//in my Page_Controller
function getWorkshops()
{
if($Workshops = DataObject::get('Workshop'))
{
return $Workshops->map('Workshopname', 'Workshopname', 'Please Select');
}
else
{
return array('No Objects found');
}
}
function getWorkshopTimes()
{
if($Workshops = DataObject::get('Workshoptraining'))
{
return $Workshops->map('Time', 'Time', 'Please Select');
}
else
{
return array('No Objects found');
}
}
function Form(){
$fields = new FieldSet(
new DropdownField(
'Workshops',
'Please choose an object',
$this->getWorkshops()
),
new DropdownField(
'Time',
'Please choose an object',
$this->getWorkshopTimes()
)
);
I hope, that I´ve described what I want and the problem clear enough and hope someone can help.