mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°7063 - Forms SDK - Add Symfony forms component
error forms issue
This commit is contained in:
@@ -37,11 +37,11 @@ class TestController extends AbstractAppController
|
||||
$oFactory = FormHelper::CreateSampleFormFactory($oFormManager, $oRouter);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $this->createNotFoundException('unable to load object Person 1');
|
||||
throw $this->createNotFoundException('unable to create sample form factory', $e);
|
||||
}
|
||||
|
||||
// get the form
|
||||
$oForm = $oFactory->GetForm();
|
||||
$oForm = $oFactory->CreateForm();
|
||||
|
||||
// handle request
|
||||
$oForm->handleRequest($oRequest);
|
||||
@@ -52,9 +52,17 @@ class TestController extends AbstractAppController
|
||||
// retrieve form data
|
||||
$data = $oForm->getData();
|
||||
|
||||
return $this->redirectToRoute('app_success');
|
||||
// let's adaptaters save theirs data
|
||||
foreach($oFactory->GetAllAdapters() as $oAdapter){
|
||||
$oAdapter->UpdateFieldsData($data);
|
||||
}
|
||||
|
||||
dump($data);
|
||||
|
||||
// return $this->redirectToRoute('app_success');
|
||||
}
|
||||
|
||||
// render view
|
||||
return $this->render('formSDK/form.html.twig', [
|
||||
'form' => $oForm->createView(),
|
||||
'theme' => 'formSDK/themes/portal.html.twig'
|
||||
@@ -70,17 +78,18 @@ class TestController extends AbstractAppController
|
||||
$oFactory = FormHelper::CreateSampleFormFactory($oFormManager, $oRouter);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $this->createNotFoundException('unable to load object Person 1');
|
||||
throw $this->createNotFoundException('unable to create sample form factory');
|
||||
}
|
||||
|
||||
// get the forms (named instances)
|
||||
$oForm1 = $oFactory->GetForm('form1');
|
||||
$oForm2 = $oFactory->GetForm('form2');
|
||||
$oForm1 = $oFactory->CreateForm('form1');
|
||||
$oForm2 = $oFactory->CreateForm('form2');
|
||||
|
||||
// handle request
|
||||
$oForm1->handleRequest($oRequest);
|
||||
$oForm2->handleRequest($oRequest);
|
||||
|
||||
// render view
|
||||
return $this->render('formSDK/theme.html.twig', [
|
||||
'name1' => 'Portail',
|
||||
'name2' => 'Console',
|
||||
@@ -95,7 +104,7 @@ class TestController extends AbstractAppController
|
||||
#[Route('/formSDK/ajax_select', name: 'formSDK_ajax_select')]
|
||||
public function ajax(Request $oRequest): Response
|
||||
{
|
||||
$oJson = file_get_contents('sources/FormSDK/Resources/dogs.json');
|
||||
$oJson = file_get_contents('sources/FormImplementation/Resources/dogs.json');
|
||||
$aDogs = json_decode($oJson, true);
|
||||
$sQuery = $oRequest->request->get('query');
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Combodo\iTop\FormImplementation\Helper;
|
||||
|
||||
use Combodo\iTop\Controller\AbstractAppController;
|
||||
use Combodo\iTop\FormSDK\Service\FormManager;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use MetaModel;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
@@ -28,7 +29,7 @@ class FormHelper
|
||||
$oFormFactory = $oFormManager->CreateFactory();
|
||||
|
||||
// add X person forms...
|
||||
for($i = 0 ; $i < 2 ; $i++){
|
||||
for($i = 0 ; $i < 5 ; $i++){
|
||||
|
||||
// retrieve person
|
||||
$oPerson = MetaModel::GetObject('Person', $i+1);
|
||||
@@ -49,8 +50,7 @@ class FormHelper
|
||||
// tel - text with pattern
|
||||
$oFormFactory->AddTextField('tel', [
|
||||
'label' => 'Tel',
|
||||
'constraints' => new Regex(['pattern' => '+{33}(0) 00 00 00 00']),
|
||||
// 'constraints' => new Regex(['pattern' => '/^[1-6]\d{0,5}$/']),
|
||||
'constraints' => new Regex(['pattern' => '/\+33\(\d\) \d\d \d\d \d\d \d\d/'], null, '+{33}(0) 00 00 00 00'),
|
||||
'required' => false
|
||||
], null);
|
||||
|
||||
@@ -61,6 +61,25 @@ class FormHelper
|
||||
'required' => false
|
||||
], new DateTime('1979/06/27'));
|
||||
|
||||
// count - number
|
||||
$oFormFactory->AddNumberField('count', [
|
||||
'label' => 'Compteur',
|
||||
'required' => false
|
||||
], 10);
|
||||
|
||||
// interval - duration
|
||||
$oFormFactory->AddDurationField('interval', [
|
||||
'label' => 'Fréquence',
|
||||
'input' => 'array',
|
||||
'with_minutes' => true,
|
||||
'with_seconds' => true,
|
||||
'with_weeks' => true,
|
||||
'with_days' => false,
|
||||
'attr' => [
|
||||
'class' => 'form_interval_horizontal'
|
||||
]
|
||||
], ['days' => '12', 'hours' => '13', 'years' => '10', 'months' => '6', 'minutes' => '0', 'seconds' => '0', 'weeks' => '3']);
|
||||
|
||||
// ready
|
||||
$oFormFactory->AddSwitchField('notify', [
|
||||
'label' => 'Veuillez m\'avertir en cas de changement',
|
||||
|
||||
Reference in New Issue
Block a user