-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
When adding a header action to an inputfield via Inputfield::addHeaderAction() the logical place to do this is at renderReady. But this method can be called multiple times (e.g. in Repeater rendering), and therefore duplicates of the action get added.
This would be avoided if it was possible to specify the array key used when the action is added to the array. The action name seems like a good candidate for the key name rather than adding a new setting for the purpose.
Using an array key for header actions would also be useful if header actions become used more widely, as it would then be possible to easily replace the behaviour of a particular action via a hook.
My proposal is to update Inputfield:addHeaderAction() to:
public function addHeaderAction(array $settings = array()) {
if(!empty($settings['setAll'])) {
if(is_array($settings['setAll'])) {
$this->headerActions = array_values($settings['setAll']);
}
} else {
if(isset($settings['name'])) {
$this->headerActions[$settings['name']] = $settings; // add new action with key
} else {
$this->headerActions[] = $settings; // add new action
}
}
return $this->headerActions; // return all
}Metadata
Metadata
Assignees
Labels
No labels