Release of v5.1.1-alpha3
Add edit and create options to the ModalSelect Field (in Joomla 5).
This commit is contained in:
@@ -24,8 +24,8 @@ use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use VDM\Joomla\Data\Factory as DataFactory;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Data\Factory as DataFactory;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
@@ -80,6 +80,51 @@ class Admin_viewController extends FormController
|
||||
*/
|
||||
protected int $refid;
|
||||
|
||||
|
||||
/**
|
||||
* Method to edit an existing record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key
|
||||
* (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if access level check and checkout passes, false otherwise.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function edit($key = null, $urlVar = null)
|
||||
{
|
||||
// for modal title key selection (unique key to do mapping)
|
||||
$titleKey = $this->input->get('titleKey', 'id', 'word');
|
||||
$guid = null;
|
||||
$value = null;
|
||||
|
||||
// Determine the name of the primary key for the data.
|
||||
if (empty($key))
|
||||
{
|
||||
$model = $this->getModel();
|
||||
$table = $model->getTable();
|
||||
$key = $table->getKeyName();
|
||||
}
|
||||
|
||||
if ($titleKey === 'guid')
|
||||
{
|
||||
$guid = $this->input->get('guid', null, 'string');
|
||||
}
|
||||
|
||||
if ($guid !== null && GuidHelper::valid($guid))
|
||||
{
|
||||
$value = GuidHelper::item($guid, 'admin_view', 'a.' . $key, 'componentbuilder');
|
||||
}
|
||||
|
||||
if ($value !== null)
|
||||
{
|
||||
$this->input->set($key, $value);
|
||||
}
|
||||
|
||||
return parent::edit($key, $urlVar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
@@ -283,6 +328,15 @@ class Admin_viewController extends FormController
|
||||
)
|
||||
);
|
||||
}
|
||||
// When editing in modal then redirect to modalreturn layout
|
||||
elseif ($cancel && $this->input->get('layout') === 'modal')
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
$return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id)
|
||||
. '&layout=modalreturn&from-task=cancel';
|
||||
|
||||
$this->setRedirect(Route::_($return, false));
|
||||
}
|
||||
return $cancel;
|
||||
}
|
||||
|
||||
@@ -365,6 +419,15 @@ class Admin_viewController extends FormController
|
||||
*/
|
||||
protected function postSaveHook(BaseDatabaseModel $model, $validData = [])
|
||||
{
|
||||
if ($this->input->get('layout') === 'modal' && $this->task === 'save')
|
||||
{
|
||||
// When editing in modal then redirect to modalreturn layout
|
||||
$id = $model->getState('admin_view.id', '');
|
||||
$return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id)
|
||||
. '&layout=modalreturn&from-task=save';
|
||||
|
||||
$this->setRedirect(Route::_($return, false));
|
||||
}
|
||||
// linked tables to update
|
||||
$_tables_array = [
|
||||
'admin_fields' => 'admin_view',
|
||||
|
Reference in New Issue
Block a user