mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-22 08:42:17 +02:00
N°7063 - Forms SDK - Add Symfony forms component
error forms issue
This commit is contained in:
@@ -25,8 +25,10 @@ use Combodo\iTop\FormSDK\Field\FormFieldTypeEnumeration;
|
||||
use LogAPI;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateIntervalType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
@@ -100,25 +102,39 @@ class SymfonyBridge
|
||||
|
||||
case FormFieldTypeEnumeration::DB_OBJECT:
|
||||
$aOptions = $oFormDescription->GetOptions();
|
||||
$aItems = [];
|
||||
foreach ($aOptions['descriptions'] as $oChildFormDescription){
|
||||
$aFields = [];
|
||||
foreach ($aOptions['fields'] as $oChildFormDescription){
|
||||
$aSymfony = $this->ToSymfonyFormType($oChildFormDescription);
|
||||
$aItems[] = $aSymfony;
|
||||
$aFields[] = $aSymfony;
|
||||
}
|
||||
$aOptions['descriptions'] = $aItems;
|
||||
$aOptions['fields'] = $aFields;
|
||||
return [
|
||||
'name' => $oFormDescription->GetName(),
|
||||
'type' => FormObjectType::class,
|
||||
'options' => $aOptions
|
||||
];
|
||||
|
||||
case FormFieldTypeEnumeration::NUMBER:
|
||||
return [
|
||||
'name' => $oFormDescription->GetName(),
|
||||
'type' => NumberType::class,
|
||||
'options' => $oFormDescription->GetOptions()
|
||||
];
|
||||
|
||||
case FormFieldTypeEnumeration::DURATION:
|
||||
return [
|
||||
'name' => $oFormDescription->GetName(),
|
||||
'type' => DateIntervalType::class,
|
||||
'options' => $oFormDescription->GetOptions()
|
||||
];
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Symfony form.
|
||||
* Create Symfony form.
|
||||
*
|
||||
* @param array $aDescriptions
|
||||
* @param array $aData
|
||||
@@ -126,7 +142,7 @@ class SymfonyBridge
|
||||
*
|
||||
* @return \Symfony\Component\Form\FormInterface
|
||||
*/
|
||||
public function GetForm(array $aDescriptions, array $aData, ?string $sName = null): FormInterface
|
||||
public function CreateForm(array $aDescriptions, array $aData, ?string $sName = null): FormInterface
|
||||
{
|
||||
// create Symfony form builder
|
||||
if($sName !== null){
|
||||
|
||||
Reference in New Issue
Block a user