Hey,
I'm trying to find out if there is a way in which you can check whether the popup opened from a ComplexTableField is on editing/viewing (magnyfing glass icon or notebook icon being clicked) or adding mode (add new DataObject button).
The DataObject created is associated with the current admin user logged in only when creating a new DataObject. When editing, the member must be selectable through a dropdown (of course, viewing will just show the Member as readonly).
What I need in my DataObject is something like this:
function getCMSFields_forPopup() {
$members = DataObject::get("Member") ;
$loggedInMember = Member::currentUser();
if($addMode){
$memberID = $loggedInMember->ID;
}else{
$memberID = $this->MemberID;
}
return new FieldSet(
new DropdownField( "MemberID", "Creator", $members->toDropdownMap("ID", "Name"), $memberID, null, 'Select Member' )
);
}
replacing $addMode for whatever it suits to check the mode.
I'm using 2.4.
Any help will be much appreciated! Thanks in advance!
Santiago