mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°8772 - form controller
This commit is contained in:
@@ -16,10 +16,10 @@ class TurboForm extends UIContentBlock
|
||||
public const BLOCK_CODE = 'ibo-form';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/turbo-form/layout';
|
||||
|
||||
/** @var string */
|
||||
protected $sOnSubmitJsCode;
|
||||
/** @var string */
|
||||
protected $sAction;
|
||||
/** @var string|null */
|
||||
protected ?string $sOnSubmitJsCode;
|
||||
/** @var string|null */
|
||||
protected ?string $sAction;
|
||||
private FormView $oFormView;
|
||||
|
||||
public function __construct(FormView $oFormView, string $sId = null)
|
||||
@@ -45,7 +45,7 @@ class TurboForm extends UIContentBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function GetAction(): ?string
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ use Combodo\iTop\Forms\Block\FormBlockService;
|
||||
use Combodo\iTop\Forms\Compiler\FormsCompiler;
|
||||
use Combodo\iTop\Forms\Compiler\FormsController;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Class TurboFormUIBlockFactory
|
||||
@@ -29,13 +30,21 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
|
||||
/**
|
||||
* @api
|
||||
*
|
||||
* @param \Symfony\Component\Form\FormView $oFormView
|
||||
* @param string|null $sAction
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm An HTML form in which you can add UIBlocks
|
||||
*/
|
||||
public static function MakeStandard(FormView $oFormView, string $sId = null): TurboForm
|
||||
public static function MakeStandard(FormView $oFormView, string $sAction = null, string $sId = null): TurboForm
|
||||
{
|
||||
return new TurboForm($oFormView, $sId);
|
||||
$oTurboForm = new TurboForm($oFormView, $sId);
|
||||
if (!is_null($sAction)) {
|
||||
$oTurboForm->setAction($sAction);
|
||||
}
|
||||
|
||||
return $oTurboForm;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +54,7 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm
|
||||
*/
|
||||
public static function MakeForDashlet(string $sDashletId, string $sAction = null, string $sId = null): TurboForm
|
||||
public static function MakeForDashlet(string $sDashletId, string $sId = null): TurboForm
|
||||
{
|
||||
$oBlockForm = FormBlockService::GetInstance()->GetFormBlockById($sDashletId);
|
||||
$oController = new FormsController();
|
||||
@@ -53,9 +62,7 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
$oForm = $oBuilder->getForm();
|
||||
|
||||
$oTurboForm = new TurboForm($oForm->createView(), $sId);
|
||||
if (!is_null($sAction)) {
|
||||
$oTurboForm->SetAction($sAction);
|
||||
}
|
||||
$oTurboForm->SetAction(utils::GetAbsoluteUrlAppRoot()."pages/UI.php?route=forms.dashlet_configuration&dashlet_code=$sDashletId");
|
||||
|
||||
return $oTurboForm;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
namespace Combodo\iTop\Forms\Block\Base;
|
||||
|
||||
use Combodo\iTop\Forms\Block\AbstractTypeFormBlock;
|
||||
use Combodo\iTop\Forms\IO\Converter\BoolConverter;
|
||||
use Combodo\iTop\Forms\IO\Format\BooleanIOFormat;
|
||||
use Combodo\iTop\Forms\Register\IORegister;
|
||||
use Combodo\iTop\Forms\Register\OptionsRegister;
|
||||
|
||||
22
sources/Forms/Block/Base/HiddenFormBlock.php
Normal file
22
sources/Forms/Block/Base/HiddenFormBlock.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Forms\Block\Base;
|
||||
|
||||
use Combodo\iTop\Forms\Block\AbstractTypeFormBlock;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
|
||||
class HiddenFormBlock extends AbstractTypeFormBlock
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function GetFormType(): string
|
||||
{
|
||||
return HiddenType::class;
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,17 @@ class FormsController extends Controller
|
||||
{
|
||||
public const ROUTE_NAMESPACE = 'forms';
|
||||
|
||||
public function OperationDisplayForm()
|
||||
public function OperationDashletConfiguration()
|
||||
{
|
||||
try {
|
||||
$oRequest = $this->getRequest();
|
||||
$sId = $oRequest->query->get('dashlet_code');
|
||||
|
||||
// Get the form block from the service (and the compiler)
|
||||
$oFormBlock = FormBlockService::GetInstance()->GetFormBlockById('VerySimpleForm');
|
||||
$oFormBlock = FormBlockService::GetInstance()->GetFormBlockById($sId);
|
||||
$oBuilder = $this->GetFormBuilder($oFormBlock, []);
|
||||
$oForm = $oBuilder->getForm();
|
||||
$oForm->handleRequest($this->GetRequest());
|
||||
$oForm->handleRequest($oRequest);
|
||||
|
||||
if ($oForm->isSubmitted()) {
|
||||
if ($oForm->isValid()) {
|
||||
@@ -46,6 +49,7 @@ class FormsController extends Controller
|
||||
|
||||
$this->DisplayPage([
|
||||
'form' => $oForm->createView(),
|
||||
'sAction' => '',
|
||||
], 'BasicForm');
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user