In core we use the layout
modal
in the cancel
task in the controller for modalselect
closing.
This is implemented in several controllers. it would make sense to move this functionality to the FromController cancel
method. This function already has similar functionality for redirection logic.
Additionally in the postSaveHook
in the same Controller is used for save
operation redirection and should be added to the core at the same time.
Move selectmodal functionality to FromController
Something like that but a bit simplified:
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return boolean True if access level checks pass, false otherwise.
*
* @since _0_VERSION_0_
*/
public function cancel($key = null)
{
$result = parent::cancel($key);
// When editing in modal then redirect to modalreturn layout
if ($result && $this->input->get('layout') === 'modal') {
$id = $this->input->get('_0_MVC_TABLE_SCHEMA_ID_0_', '');
$return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id, '_0_MVC_TABLE_SCHEMA_ID_0_')
. '&layout=modalreturn&from-task=cancel';
$this->setRedirect(Route::_($return, false));
}
return $result;
}
/**
* Function that allows child controller access to model data
* after the data has been saved.
*
* @param BaseDatabaseModel $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since _0_VERSION_0_
*/
protected function postSaveHook(BaseDatabaseModel $model, $validData = [])
{
// When editing in modal then redirect to modalreturn layout
if ($this->input->get('layout') === 'modal' && $this->task === 'save') {
$id = $model->getState('_0_MVC_EDIT_0_.id');
$return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id, '_0_MVC_TABLE_SCHEMA_ID_0_')
. '&layout=modalreturn&from-task=save';
$this->setRedirect(Route::_($return, false));
}
}
Labels |
Added:
No Code Attached Yet
|
Labels |
Added:
Feature
|
Sounds like a good idea
Labels |
Added:
Maintainers Checked
|
Additonal the
addModalToolbar()
method in theHtmlView
could be added toFormView
as well.Example code: