ADD B4 Actions: Save and View
This commit is contained in:
19
admin/src/Controller/PartController.php
Normal file
19
admin/src/Controller/PartController.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Depot.Administrator
|
||||
* @subpackage com_depot
|
||||
* @author Thomas Kuschel <thomas@kuschel.at>
|
||||
* @copyright (C) 2023 KW4NZ, <https://www.kuschel.at>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.md
|
||||
* @since 0.0.4
|
||||
*/
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Controller;
|
||||
|
||||
use Joomla\CMS\MVC\Controller\FormController;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
class PartController extends FormController
|
||||
{
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\Model;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
@ -26,4 +27,16 @@ class PartModel extends AdminModel
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
protected function loadFormData()
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$data = $app->getUserState('com_depot.edit.part.data', []);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -10,10 +10,13 @@
|
||||
|
||||
namespace KW4NZ\Component\Depot\Administrator\View\Part;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
// use Joomla\CMS\MVC\View\GenericDataException;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View to edit an article.
|
||||
@ -43,8 +46,8 @@ class HtmlView extends BaseHtmlView
|
||||
*
|
||||
* @return mixed A string if successful, otherwise an Error object.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 1.6
|
||||
* @throws \Exception
|
||||
* @since 1.6
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
@ -54,7 +57,19 @@ class HtmlView extends BaseHtmlView
|
||||
// if (count($errors = $this->get('Errors'))) {
|
||||
// throw new GenericDataException(implode("\n", $errors), 500);
|
||||
// }
|
||||
$this->addToolbar();
|
||||
|
||||
return parent::display($tpl);
|
||||
}
|
||||
|
||||
protected function addToolbar()
|
||||
{
|
||||
Factory::getApplication()->getInput()->set('hidemainmenu', true);
|
||||
|
||||
ToolbarHelper::title('Part: Add');
|
||||
|
||||
ToolbarHelper::apply('part.apply');
|
||||
ToolbarHelper::save('part.save');
|
||||
ToolbarHelper::cancel('part.cancel', 'JTOOLBAR_CLOSE');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user