From 97ce036cbe1d862a23fb6907ba1f6ff5788821cf Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 11 Oct 2013 17:23:40 +0200 Subject: [PATCH] start area configuration tempalte --- core/lib/Thelia/Config/Resources/config.xml | 5 +- core/lib/Thelia/Form/Area/AreaCountryForm.php | 89 +++++++++++++++++++ templates/admin/default/category-edit.html | 2 +- .../default/shipping-configuration-edit.html | 50 +++++------ 4 files changed, 116 insertions(+), 30 deletions(-) create mode 100644 core/lib/Thelia/Form/Area/AreaCountryForm.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 34803ce31..aa8236000 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -125,8 +125,9 @@
- - + + + diff --git a/core/lib/Thelia/Form/Area/AreaCountryForm.php b/core/lib/Thelia/Form/Area/AreaCountryForm.php new file mode 100644 index 000000000..c511e0b3c --- /dev/null +++ b/core/lib/Thelia/Form/Area/AreaCountryForm.php @@ -0,0 +1,89 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form\Area; + +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Form\BaseForm; + + +/** + * Class AreaCountryForm + * @package Thelia\Form\Area + * @author Manuel Raynaud + */ +class AreaCountryForm extends BaseForm +{ + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + $this->formBuilder + ->add('area_id', 'integer', array( + 'constraints' => array( + new GreaterThan(array('value' => 0)), + new NotBlank() + ) + + )) + ->add('country_id', 'integer', array( + 'constraints' => array( + new GreaterThan(array('value' => 0)), + new NotBlank() + ), + 'label_attr' => array( + 'for' => 'area_country' + ), + 'label' => Translator::getInstance()->trans('Country') + )); + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return 'thelia_area_country'; + } +} \ No newline at end of file diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index f8b564822..78cb7b681 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -66,7 +66,7 @@ {form_hidden_fields form=$form} {form_field form=$form field='success_url'} - + {/form_field} {form_field form=$form field='locale'} diff --git a/templates/admin/default/shipping-configuration-edit.html b/templates/admin/default/shipping-configuration-edit.html index b17dc6de4..7bf8164f9 100644 --- a/templates/admin/default/shipping-configuration-edit.html +++ b/templates/admin/default/shipping-configuration-edit.html @@ -28,23 +28,33 @@
- + {form name="thelia.admin.area.country"} - + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='area_id'} + + {/form_field} + {form_field form=$form field='country_id'} +
- + {loop name="country-without-area" type="country" with_area="0" backend_context="1" lang=$lang_id} + + {/loop}
- + {/form_field} - + {/form}
@@ -57,38 +67,24 @@ + {loop name="country-area" type="country" area=$area_id backend_context="1"} - Wallis-et-Futuna + {$TITLE} - - Polynésie française - - - - - - - - USA - Alabama - - - - - - + {/loop}
- +
- +