I was looking a while for the answer to this but couldn't find it.
I have a DataObject "Testimonial" that is a part of a Page class "BookPage", and I've also added testimonial as a ModelAdmin to list all the testimonials and the books they are under. I used the ModelAdmin to switch Books that the testimonial belongs in, with a "BookPage" dropdown....
public function getCMSFields(){
$fields = new FieldList();
...
$fields->push( new DropdownField(
'BookPageID',
'Please choose a Book',
$this->getBookSelection() ) );
...
function getBookSelection()
{
if($Pages = DataObject::get('BookPage'))
{
return $Pages->map('ID', 'Title', 'Please Select');
}
else
{
return array('No Objects found');
}
}
I'd like to be able to show the dropdown menu only when I'm adding or editing a testimonial from the modelAdmin (/admin/testimonial/Testimonial/EditForm/field/Testimonial/item/2/edit) ,
but not when I'm accessing the testimonial from editing the pages (/admin/pages/edit/EditForm/field/Testimonials/item/new).