1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-28 10:20:45 +02:00

Added option to override/modify default Create/Update buttons (triggers)

eg. $this->setDefaultTrigger(array('cancel' => array(LAN_CANCEL, 'cancel'))); // display only a cancel button.
This commit is contained in:
Cameron
2019-05-09 15:14:56 -07:00
parent e6c154f47d
commit 0688bc3aea

View File

@@ -1647,6 +1647,12 @@ class e_admin_controller
* @var string default action name
*/
protected $_default_action = 'index';
/**
* @var string default trigger action.
*/
protected $_default_trigger = 'auto';
/**
* List (numerical array) of only allowed for this controller actions
@@ -2358,6 +2364,14 @@ class e_admin_controller
return $this->_default_action;
}
public function getDefaultTrigger()
{
return $this->_default_trigger;
}
/**
* Set default action
* @param string $action_name
@@ -2369,6 +2383,21 @@ class e_admin_controller
return $this;
}
/**
* Set default trigger
* @param string|array $triggers 'auto' or array of triggers
* @example $triggers['submit'] = array(LAN_UPDATE, 'update', $model->getId());
$triggers['submit'] = array(LAN_CREATE, 'create', 0);
$triggers['cancel'] = array(LAN_CANCEL, 'cancel');
* @return e_admin_controller
*/
public function setDefaultTrigger($triggers)
{
$this->_default_trigger = $triggers;
return $this;
}
/**
* @return boolean
*/
@@ -6563,10 +6592,11 @@ class e_admin_form_ui extends e_form
'footer' => $form_end, //XXX Unused?
'after_submit_options' => $controller->getAfterSubmitOptions(), // or true for default redirect options
'after_submit_default' => $request->getPosted('__after_submit_action', $controller->getDefaultAction()), // or true for default redirect options
'triggers' => 'auto', // standard create/update-cancel triggers
'triggers' => $controller->getDefaultTrigger(), // standard create/update-cancel triggers
)
)
);
$models[] = $controller->getModel();
return $this->renderCreateForm($forms, $models, e_AJAX_REQUEST);