mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°7063 - Forms SDK - Add Symfony forms component
error forms issue
This commit is contained in:
@@ -413,8 +413,8 @@ return array(
|
||||
'Combodo\\iTop\\FormSDK\\Service\\FormFactoryBuilderTrait' => $baseDir . '/sources/FormSDK/Service/FormFactoryBuilderTrait.php',
|
||||
'Combodo\\iTop\\FormSDK\\Service\\FormManager' => $baseDir . '/sources/FormSDK/Service/FormManager.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\SymfonyBridge' => $baseDir . '/sources/FormSDK/Symfony/SymfonyBridge.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Compound\\CollectionType' => $baseDir . '/sources/FormSDK/Symfony/Type/Compound/CollectionType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Compound\\FieldsetType' => $baseDir . '/sources/FormSDK/Symfony/Type/Compound/FieldsetType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Compound\\TableCollectionType' => $baseDir . '/sources/FormSDK/Symfony/Type/Compound/TableCollectionType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Layout\\ColumnType' => $baseDir . '/sources/FormSDK/Symfony/Type/Layout/ColumnType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Layout\\LayoutType' => $baseDir . '/sources/FormSDK/Symfony/Type/Layout/LayoutType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Layout\\RowType' => $baseDir . '/sources/FormSDK/Symfony/Type/Layout/RowType.php',
|
||||
|
||||
@@ -822,8 +822,8 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
|
||||
'Combodo\\iTop\\FormSDK\\Service\\FormFactoryBuilderTrait' => __DIR__ . '/../..' . '/sources/FormSDK/Service/FormFactoryBuilderTrait.php',
|
||||
'Combodo\\iTop\\FormSDK\\Service\\FormManager' => __DIR__ . '/../..' . '/sources/FormSDK/Service/FormManager.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\SymfonyBridge' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/SymfonyBridge.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Compound\\CollectionType' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/Type/Compound/CollectionType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Compound\\FieldsetType' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/Type/Compound/FieldsetType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Compound\\TableCollectionType' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/Type/Compound/TableCollectionType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Layout\\ColumnType' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/Type/Layout/ColumnType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Layout\\LayoutType' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/Type/Layout/LayoutType.php',
|
||||
'Combodo\\iTop\\FormSDK\\Symfony\\Type\\Layout\\RowType' => __DIR__ . '/../..' . '/sources/FormSDK/Symfony/Type/Layout/RowType.php',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
'name' => 'combodo/itop',
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'reference' => '153027434d1a860bbb424fdbf1bd6c7e47217e27',
|
||||
'reference' => '816ab41e27072b7058287ac4608d4a099f4f8912',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@@ -22,7 +22,7 @@
|
||||
'combodo/itop' => array(
|
||||
'pretty_version' => 'dev-develop',
|
||||
'version' => 'dev-develop',
|
||||
'reference' => '153027434d1a860bbb424fdbf1bd6c7e47217e27',
|
||||
'reference' => '816ab41e27072b7058287ac4608d4a099f4f8912',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
||||
@@ -46,7 +46,7 @@ enum FormFieldTypeEnumeration
|
||||
public function GetAvailableOptions() : array
|
||||
{
|
||||
// global options
|
||||
$aOptions = ['required', 'disabled', 'attr', 'label', 'label_attr', 'help'];
|
||||
$aOptions = ['required', 'disabled', 'attr', 'label', 'label_attr', 'help', 'row_attr'];
|
||||
|
||||
// : specific options
|
||||
return match ($this) {
|
||||
|
||||
@@ -27,14 +27,6 @@ namespace Combodo\iTop\FormSDK\Service\FactoryAdapter;
|
||||
*/
|
||||
interface FormFactoryAdapterInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Return adapter identifier.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetIdentifier() : string;
|
||||
|
||||
/**
|
||||
* Return fields descriptions.
|
||||
*
|
||||
|
||||
@@ -29,7 +29,7 @@ use ExceptionLog;
|
||||
use MetaModel;
|
||||
|
||||
/**
|
||||
* Form manipulation for DBObject.
|
||||
* Form factory adapter for DBObject.
|
||||
*
|
||||
* @package FormSDK
|
||||
* @since 3.X.0
|
||||
@@ -73,7 +73,7 @@ final class FormFactoryObjectAdapter implements FormFactoryAdapterInterface
|
||||
* @throws \CoreException
|
||||
* @throws \ArchivedObjectException
|
||||
*/
|
||||
protected function GetAttributeData(string $sAttributeCode) : mixed
|
||||
private function GetAttributeData(string $sAttributeCode) : mixed
|
||||
{
|
||||
return $this->oDBObject->Get($sAttributeCode);
|
||||
}
|
||||
@@ -140,12 +140,33 @@ final class FormFactoryObjectAdapter implements FormFactoryAdapterInterface
|
||||
*/
|
||||
private function GetAttributeName(string $sAttributeCode) : string
|
||||
{
|
||||
return $this->bGroup ? $sAttributeCode : $this->GetIdentifier() . '_' . $sAttributeCode;
|
||||
return $this->bGroup ? $sAttributeCode : $this->GetAdapterIdentifier() . '_' . $sAttributeCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get adapter label.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetAdapterLabel(): string
|
||||
{
|
||||
return get_class($this->oDBObject) . ' ' . $this->oDBObject->GetKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get adapter identifier.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetAdapterIdentifier(): string
|
||||
{
|
||||
return get_class($this->oDBObject) . '_' . $this->oDBObject->GetKey();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function GetFieldsData() : array
|
||||
{
|
||||
// prepare data...
|
||||
$aData = [];
|
||||
foreach ($this->aAttributes as $sAttributeCode => $oValue){
|
||||
try {
|
||||
@@ -157,9 +178,10 @@ final class FormFactoryObjectAdapter implements FormFactoryAdapterInterface
|
||||
}
|
||||
}
|
||||
|
||||
// group
|
||||
if($this->bGroup){
|
||||
return [
|
||||
$this->GetIdentifier() => $aData
|
||||
$this->GetAdapterIdentifier() => $aData
|
||||
];
|
||||
}
|
||||
else{
|
||||
@@ -184,7 +206,7 @@ final class FormFactoryObjectAdapter implements FormFactoryAdapterInterface
|
||||
}
|
||||
|
||||
if($this->bGroup){
|
||||
$oGroupDescriptions = new FormFieldDescription($this->GetIdentifier(), FormFieldTypeEnumeration::FIELDSET, [
|
||||
$oGroupDescriptions = new FormFieldDescription($this->GetAdapterIdentifier(), FormFieldTypeEnumeration::FIELDSET, [
|
||||
'fields' => $aFieldsDescriptions,
|
||||
'layout' => [
|
||||
':row_1' => [
|
||||
@@ -193,29 +215,18 @@ final class FormFactoryObjectAdapter implements FormFactoryAdapterInterface
|
||||
],
|
||||
]
|
||||
]);
|
||||
return [$this->GetIdentifier() => $oGroupDescriptions];
|
||||
return [$this->GetAdapterIdentifier() => $oGroupDescriptions];
|
||||
}
|
||||
else{
|
||||
return $aFieldsDescriptions;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetLabel(): string
|
||||
{
|
||||
return get_class($this->oDBObject) . ' ' . $this->oDBObject->GetKey();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function GetIdentifier(): string
|
||||
{
|
||||
return get_class($this->oDBObject) . '_' . $this->oDBObject->GetKey();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function UpdateFieldsData(array $aFormData) : bool
|
||||
{
|
||||
if($this->bGroup){
|
||||
$aFormData = $aFormData[$this->GetIdentifier()];
|
||||
$aFormData = $aFormData[$this->GetAdapterIdentifier()];
|
||||
}
|
||||
|
||||
foreach ($this->aAttributes as $sAttCode => $aValue){
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Combodo\iTop\FormSDK\Symfony;
|
||||
|
||||
use Combodo\iTop\FormSDK\Field\FormFieldDescription;
|
||||
use Combodo\iTop\FormSDK\Field\FormFieldTypeEnumeration;
|
||||
use Combodo\iTop\FormSDK\Symfony\Type\Compound\CollectionType;
|
||||
use Combodo\iTop\FormSDK\Symfony\Type\Compound\TableCollectionType;
|
||||
use Combodo\iTop\FormSDK\Symfony\Type\Compound\FieldsetType;
|
||||
use Combodo\iTop\FormSDK\Symfony\Type\Layout\ColumnType;
|
||||
use Combodo\iTop\FormSDK\Symfony\Type\Layout\RowType;
|
||||
@@ -92,7 +92,7 @@ class SymfonyBridge
|
||||
FormFieldTypeEnumeration::FIELDSET => FieldsetType::class,
|
||||
FormFieldTypeEnumeration::NUMBER => IntegerType::class,
|
||||
FormFieldTypeEnumeration::DURATION => DateIntervalType::class,
|
||||
FormFieldTypeEnumeration::COLLECTION => CollectionType::class,
|
||||
FormFieldTypeEnumeration::COLLECTION => TableCollectionType::class,
|
||||
FormFieldTypeEnumeration::FILE => FileType::class,
|
||||
default => null,
|
||||
};
|
||||
|
||||
@@ -29,12 +29,12 @@ use Symfony\Component\Form\Util\StringUtil;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* Type representing a collection;
|
||||
* Type representing a collection as a table;
|
||||
*
|
||||
* @package FormSDK
|
||||
* @since 3.X.0
|
||||
*/
|
||||
class CollectionType extends AbstractType
|
||||
class TableCollectionType extends AbstractType
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
@@ -58,9 +58,4 @@ class CollectionType extends AbstractType
|
||||
$view->vars['types_labels'] = $options['types_labels'];
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return 'itop_collection'; // need a specific block prefix as we create a CollectionType that's already exist in Symfony namespace
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
{{ form_row(form, {'attr' : {'class' : attr.class|default('') ~ ' form-compound-fieldset'}}) }}
|
||||
{%- endblock fieldset_row -%}
|
||||
|
||||
{%- block itop_collection_widget -%}
|
||||
{%- block table_collection_widget -%}
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -64,4 +64,4 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{%- endblock itop_collection_widget -%}
|
||||
{%- endblock table_collection_widget -%}
|
||||
|
||||
Reference in New Issue
Block a user