N°8772 - Form turbo stream WIP

This commit is contained in:
Eric Espie
2025-10-28 15:34:19 +01:00
parent c2fcf4144b
commit 2a3de68652
2 changed files with 26 additions and 2 deletions

View File

@@ -102,6 +102,7 @@ abstract class Controller extends AbstractController
/** @var CsrfTokenManager Csrf manager (from Symfony form component @link https://symfony.com/doc/current/security/csrf.html) */
private CsrfTokenManager $oCsrfTokenManager;
private ?string $sContentType = null;
/**
* Controller constructor.
@@ -529,7 +530,9 @@ abstract class Controller extends AbstractController
$this->AddToPage($this->oTwig->render('application/forms/itop_error.html.twig', ['sControllerError' => $sErrorMsg]));
}
$this->ManageDebugExtensions($aParams);
if ($sPageType === 'html') {
$this->ManageDebugExtensions($aParams);
}
if (!empty($this->aAjaxTabs)) {
$this->oPage->AddTabContainer('TwigBaseTabContainer');
@@ -550,6 +553,7 @@ abstract class Controller extends AbstractController
foreach ($this->aBlockParams as $sKey => $value) {
$this->SetBlockParamToPage($sKey, $value);
}
$this->SetContentTypeToPage();
$this->OutputPage();
}
@@ -733,6 +737,17 @@ abstract class Controller extends AbstractController
$this->aBlockParams = $aBlockParams;
}
/**
* @param string $sContentType
*
* @return void
* @since 3.3.0
*/
public function SetContentType(string $sContentType): void
{
$this->sContentType = $sContentType;
}
/**
* @since 2.7.7 3.0.1 3.1.0 N°4760 method creation
* @see Controller::SetBreadCrumbEntry() to set breadcrumb content (by default will be title)
@@ -934,6 +949,15 @@ abstract class Controller extends AbstractController
$this->oPage->AddAjaxTab($sCode, $sURL, $bCache, $sTitle);
}
private function SetContentTypeToPage(): void
{
if (!is_null($this->sContentType)) {
$this->oPage->SetContentType($this->sContentType);
}
}
/**
* @param string $sKey
* @param $value

View File

@@ -61,7 +61,7 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
$oAttDef = \MetaModel::GetAttributeDef(strval($oClassName), strval($oAttribute));
$aValues = $oAttDef->GetAllowedValues();
$aOptions['choices'] = array_flip($aValues);
$aOptions['choices'] = array_flip($aValues ?? []);
return $aOptions;
}