From 9f70d0e4b37330dd2562323511e0b80347d6c176 Mon Sep 17 00:00:00 2001 From: Benjamin Dalsass <95754414+bdalsass@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:58:51 +0200 Subject: [PATCH] test errors --- sources/FormImplementation/Controller/TestController.php | 8 ++++---- sources/FormImplementation/Helper/FormHelper.php | 9 +++++---- .../Service/FactoryAdapter/FormFactoryObjectAdapter.php | 2 +- sources/FormSDK/Service/FormFactoryBuilderTrait.php | 5 ++++- templates/formSDK/success.html.twig | 1 + 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sources/FormImplementation/Controller/TestController.php b/sources/FormImplementation/Controller/TestController.php index 7ef802eb6..5b2da0ea1 100644 --- a/sources/FormImplementation/Controller/TestController.php +++ b/sources/FormImplementation/Controller/TestController.php @@ -48,7 +48,7 @@ class TestController extends AbstractAppController $oAdapter->UpdateFieldsData($data); } - return $this->redirectToRoute('app_success'); + return $this->redirectToRoute('app_success', ['data' => $data]); } // render view @@ -90,7 +90,7 @@ class TestController extends AbstractAppController $oAdapter->UpdateFieldsData($data); } - return $this->redirectToRoute('app_success'); + return $this->redirectToRoute('app_success', ['data' => $data]); } $oPage->add_linked_stylesheet(\utils::GetAbsoluteUrlAppRoot() . 'css/form-sdk/form.css'); @@ -202,8 +202,8 @@ class TestController extends AbstractAppController } #[Route('/success', name: 'app_success')] - public function Success(): Response + public function Success(Request $oRequest): Response { - return $this->render('formSDK/success.html.twig'); + return $this->render('formSDK/success.html.twig', ['data' => $oRequest->get('data')]); } } \ No newline at end of file diff --git a/sources/FormImplementation/Helper/FormHelper.php b/sources/FormImplementation/Helper/FormHelper.php index 948b99316..94caca6ce 100644 --- a/sources/FormImplementation/Helper/FormHelper.php +++ b/sources/FormImplementation/Helper/FormHelper.php @@ -9,6 +9,7 @@ use Combodo\iTop\FormSDK\Service\FormFactory; use Combodo\iTop\FormSDK\Service\FormManager; use DateTime; use MetaModel; +use Symfony\Bundle\FrameworkBundle\Routing\Router; use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Validator\Constraints\Length; @@ -40,7 +41,7 @@ class FormHelper 'group' => true, 'layout' => false, 'object_only' => true, - 'object_count' => 1 + 'object_count' => 10 ] ]; @@ -64,7 +65,7 @@ class FormHelper // form data $aData = [ 'city' => 'Autun', - 'tel' => '+33(6) 35 57 48 77', + 'tel' => '+33(0)6 35 57 48 77', 'birthday' => new DateTime('1979/06/27'), 'count' => 10, 'counts' => ['count1' => 10, 'count2' => 20, 'count3' => 30], @@ -119,7 +120,7 @@ class FormHelper // tel - text with pattern $oFormFactory->AddTextField('tel', [ 'label' => 'Tel', - 'constraints' => new Regex(['pattern' => '/\+33\(\d\) \d\d \d\d \d\d \d\d/'], null, '+{33}(0) 00 00 00 00'), + 'constraints' => new Regex(['pattern' => '/\+33\(\d\)\d \d\d \d\d \d\d \d\d/'], null, '+{33}(0)0 00 00 00 00'), 'required' => false ]); @@ -203,7 +204,7 @@ class FormHelper 'required' => false, ], [ - 'url' => 'http://localhost'.$oRouter->generate('formSDK_ajax_select'), + 'url' => $oRouter->generate('formSDK_ajax_select', [], Router::NETWORK_PATH), 'query_parameter' => 'query', 'value_field' => 'breed', 'label_field' => 'breed', diff --git a/sources/FormSDK/Service/FactoryAdapter/FormFactoryObjectAdapter.php b/sources/FormSDK/Service/FactoryAdapter/FormFactoryObjectAdapter.php index ead6ac113..3e58325c9 100644 --- a/sources/FormSDK/Service/FactoryAdapter/FormFactoryObjectAdapter.php +++ b/sources/FormSDK/Service/FactoryAdapter/FormFactoryObjectAdapter.php @@ -92,7 +92,7 @@ final class FormFactoryObjectAdapter implements FormFactoryAdapterInterface // compute label $sLabel = $oAttributeDefinition->GetLabel(); if(!$this->bGroup){ - $sLabel = $this->GetLabel() . ' ••• ' . $sLabel; + $sLabel = $this->GetAdapterIdentifier() . ' - ' . $sLabel; } // attribute options diff --git a/sources/FormSDK/Service/FormFactoryBuilderTrait.php b/sources/FormSDK/Service/FormFactoryBuilderTrait.php index e86e1a80a..6670bc09c 100644 --- a/sources/FormSDK/Service/FormFactoryBuilderTrait.php +++ b/sources/FormSDK/Service/FormFactoryBuilderTrait.php @@ -21,6 +21,8 @@ namespace Combodo\iTop\FormSDK\Service; use Combodo\iTop\FormSDK\Field\FormFieldDescription; use Combodo\iTop\FormSDK\Field\FormFieldTypeEnumeration; +use Symfony\Bundle\FrameworkBundle\Routing\Router; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Validator\Constraints\Regex; /** @@ -222,7 +224,7 @@ trait FormFactoryBuilderTrait 'oql' => $sOql, 'fields' => '{'.implode($aAttributesToLoad).'}', ]; - $sUrl = 'http://localhost' . $this->oRouter->generate('formSDK_object_search') . '?' . http_build_query($aAjaxData); + $sUrl = $this->oRouter->generate('formSDK_object_search', [], UrlGeneratorInterface::ABSOLUTE_URL) . '?' . http_build_query($aAjaxData); $aAjaxOptions = [ 'url' => $sUrl, 'query_parameter' => 'search', @@ -232,6 +234,7 @@ trait FormFactoryBuilderTrait 'threshold' => $iAjaxThreshold, 'configuration' => 'OQL' ]; + return $this->AddSelectAjaxField($sKey, $aOptions, $aAjaxOptions, $aAjaxData); } diff --git a/templates/formSDK/success.html.twig b/templates/formSDK/success.html.twig index 1a850da23..fe53c153a 100644 --- a/templates/formSDK/success.html.twig +++ b/templates/formSDK/success.html.twig @@ -6,6 +6,7 @@
{{ dump(data) }}
{% endblock body %} \ No newline at end of file