diff --git a/core/lib/Thelia/Form/Shipping/ShippingCreateForm.php b/core/lib/Thelia/Form/Shipping/ShippingCreateForm.php new file mode 100644 index 000000000..674777112 --- /dev/null +++ b/core/lib/Thelia/Form/Shipping/ShippingCreateForm.php @@ -0,0 +1,79 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form\Shipping; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Form\BaseForm; + + +/** + * Class ShippingCreateForm + * @package Thelia\Form\Shipping + * @author Manuel Raynaud + */ +class ShippingCreateForm 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('name', 'text', array( + 'constraints' => array( + new NotBlank() + ), + 'label_attr' => array('for' => 'shipping_name'), + 'label' => Translator::getInstance()->trans('shipping area name') + )) + + ; + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return 'thelia_shipping_creation'; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/Shipping/ShippingModificationForm.php b/core/lib/Thelia/Form/Shipping/ShippingModificationForm.php new file mode 100644 index 000000000..018e44907 --- /dev/null +++ b/core/lib/Thelia/Form/Shipping/ShippingModificationForm.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form\Shipping; +use Symfony\Component\Validator\Constraints\GreaterThan; + + +/** + * Class ShippingModificationForm + * @package Thelia\Form\Shipping + * @author Manuel Raynaud + */ +class ShippingModificationForm extends ShippingCreateForm +{ + public function buildForm() + { + parent::buildForm(); + + $this->formBuilder + ->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0))))) + ; + } + + public function getName() + { + return 'thelia_shipping_modification'; + } +} \ No newline at end of file