diff --git a/core/lib/Thelia/Core/Form/Type/TheliaType.php b/core/lib/Thelia/Core/Form/Type/TheliaType.php index 19524ec85..7aeeab3e0 100644 --- a/core/lib/Thelia/Core/Form/Type/TheliaType.php +++ b/core/lib/Thelia/Core/Form/Type/TheliaType.php @@ -39,7 +39,7 @@ class TheliaType extends AbstractType public function getParent() { - return 'form'; + return 'text'; } public function getName() diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 7897b74a0..58fe2bf74 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -152,6 +152,7 @@ class Form extends AbstractSmartyPlugin } $template->assign("attr", implode(" ", $attr)); + $template->assign("attr_list", $fieldVars["attr"]); } protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView) diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php index 901c459b3..ee9ef532d 100644 --- a/core/lib/Thelia/Form/TaxCreationForm.php +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -55,13 +55,6 @@ class TaxCreationForm extends BaseForm "required" => true, "constraints" => array( new Constraints\NotBlank(), - new Constraints\Callback( - array( - "methods" => array( - array($this, "verifyRequirements"), - ), - ) - ), ), "label" => Translator::getInstance()->trans("Type"), "label_attr" => array("for" => "type_field"), @@ -77,7 +70,7 @@ class TaxCreationForm extends BaseForm new Constraints\Callback( array( "methods" => array( - array($this, "verifyRequirements"), + array($requirementType, "verifyForm"), ), ) ), @@ -104,10 +97,10 @@ class TaxCreationForm extends BaseForm return "thelia_tax_creation"; } - public function verifyRequirements($value, ExecutionContextInterface $context) + public function verifyForm($value, ExecutionContextInterface $context) { $in = true; - + //$this->getForm()->getChildren() } } diff --git a/core/lib/Thelia/Type/AlphaNumStringListType.php b/core/lib/Thelia/Type/AlphaNumStringListType.php index 9205373ca..ccf21606d 100755 --- a/core/lib/Thelia/Type/AlphaNumStringListType.php +++ b/core/lib/Thelia/Type/AlphaNumStringListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class AlphaNumStringListType implements TypeInterface +class AlphaNumStringListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/AlphaNumStringType.php b/core/lib/Thelia/Type/AlphaNumStringType.php index f574300cb..ad9595f20 100755 --- a/core/lib/Thelia/Type/AlphaNumStringType.php +++ b/core/lib/Thelia/Type/AlphaNumStringType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class AlphaNumStringType implements TypeInterface +class AlphaNumStringType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/AnyType.php b/core/lib/Thelia/Type/AnyType.php index bf5349546..4e844c6e9 100755 --- a/core/lib/Thelia/Type/AnyType.php +++ b/core/lib/Thelia/Type/AnyType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class AnyType implements TypeInterface +class AnyType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/BaseType.php b/core/lib/Thelia/Type/BaseType.php new file mode 100644 index 000000000..7ab1a86ec --- /dev/null +++ b/core/lib/Thelia/Type/BaseType.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Type; + +use Symfony\Component\Validator\ExecutionContextInterface; + +/** + * + * @author Etienne Roudeix + * + */ +abstract class BaseType implements TypeInterface +{ + abstract public function getType(); + abstract public function isValid($value); + abstract public function getFormattedValue($value); + abstract public function getFormType(); + abstract public function getFormOptions(); + + public function verifyForm($value, ExecutionContextInterface $context) + { + if( ! $this->isValid($value) ) { + $context->addViolation("Thelia Type not matched"); + } + } +} diff --git a/core/lib/Thelia/Type/BooleanOrBothType.php b/core/lib/Thelia/Type/BooleanOrBothType.php index eacd89ffc..25f3d9994 100755 --- a/core/lib/Thelia/Type/BooleanOrBothType.php +++ b/core/lib/Thelia/Type/BooleanOrBothType.php @@ -29,7 +29,7 @@ namespace Thelia\Type; * */ -class BooleanOrBothType implements TypeInterface +class BooleanOrBothType extends BaseType { const ANY = '*'; diff --git a/core/lib/Thelia/Type/BooleanType.php b/core/lib/Thelia/Type/BooleanType.php index e231ce26a..5f36453de 100755 --- a/core/lib/Thelia/Type/BooleanType.php +++ b/core/lib/Thelia/Type/BooleanType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class BooleanType implements TypeInterface +class BooleanType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/EnumListType.php b/core/lib/Thelia/Type/EnumListType.php index 0d82e3a3e..5b54c48bf 100755 --- a/core/lib/Thelia/Type/EnumListType.php +++ b/core/lib/Thelia/Type/EnumListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class EnumListType implements TypeInterface +class EnumListType extends BaseType { protected $values = array(); diff --git a/core/lib/Thelia/Type/EnumType.php b/core/lib/Thelia/Type/EnumType.php index 91f45a308..1283acde0 100755 --- a/core/lib/Thelia/Type/EnumType.php +++ b/core/lib/Thelia/Type/EnumType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class EnumType implements TypeInterface +class EnumType extends BaseType { protected $values = array(); diff --git a/core/lib/Thelia/Type/FloatToFloatArrayType.php b/core/lib/Thelia/Type/FloatToFloatArrayType.php index 404b7e4e4..f55997f55 100755 --- a/core/lib/Thelia/Type/FloatToFloatArrayType.php +++ b/core/lib/Thelia/Type/FloatToFloatArrayType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class FloatToFloatArrayType implements TypeInterface +class FloatToFloatArrayType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/FloatType.php b/core/lib/Thelia/Type/FloatType.php index 74d71adfb..830622a86 100755 --- a/core/lib/Thelia/Type/FloatType.php +++ b/core/lib/Thelia/Type/FloatType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class FloatType implements TypeInterface +class FloatType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntListType.php b/core/lib/Thelia/Type/IntListType.php index ff87bbd4e..5fe31aa3c 100755 --- a/core/lib/Thelia/Type/IntListType.php +++ b/core/lib/Thelia/Type/IntListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntListType implements TypeInterface +class IntListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntToCombinedIntsListType.php b/core/lib/Thelia/Type/IntToCombinedIntsListType.php index dfa21310d..562e160dd 100755 --- a/core/lib/Thelia/Type/IntToCombinedIntsListType.php +++ b/core/lib/Thelia/Type/IntToCombinedIntsListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntToCombinedIntsListType implements TypeInterface +class IntToCombinedIntsListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntToCombinedStringsListType.php b/core/lib/Thelia/Type/IntToCombinedStringsListType.php index 38152fdaa..5c4327dc8 100755 --- a/core/lib/Thelia/Type/IntToCombinedStringsListType.php +++ b/core/lib/Thelia/Type/IntToCombinedStringsListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntToCombinedStringsListType implements TypeInterface +class IntToCombinedStringsListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntType.php b/core/lib/Thelia/Type/IntType.php index 7a06a50fb..5aa146e60 100755 --- a/core/lib/Thelia/Type/IntType.php +++ b/core/lib/Thelia/Type/IntType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntType implements TypeInterface +class IntType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/JsonType.php b/core/lib/Thelia/Type/JsonType.php index a1a1f5af6..502a43953 100755 --- a/core/lib/Thelia/Type/JsonType.php +++ b/core/lib/Thelia/Type/JsonType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class JsonType implements TypeInterface +class JsonType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/ModelType.php b/core/lib/Thelia/Type/ModelType.php index dadd47308..a8ab8c553 100755 --- a/core/lib/Thelia/Type/ModelType.php +++ b/core/lib/Thelia/Type/ModelType.php @@ -30,7 +30,7 @@ use Thelia\Exception\TypeException; * @author Etienne Roudeix * */ -class ModelType implements TypeInterface +class ModelType extends BaseType { protected $expectedModelActiveRecord = null; diff --git a/core/lib/Thelia/Type/ModelValidIdType.php b/core/lib/Thelia/Type/ModelValidIdType.php index 16a39359e..a9bfec7b5 100755 --- a/core/lib/Thelia/Type/ModelValidIdType.php +++ b/core/lib/Thelia/Type/ModelValidIdType.php @@ -30,7 +30,7 @@ use Thelia\Exception\TypeException; * @author Etienne Roudeix * */ -class ModelValidIdType implements TypeInterface +class ModelValidIdType extends BaseType { protected $expectedModelActiveRecordQuery = null; diff --git a/core/lib/Thelia/Type/TypeInterface.php b/core/lib/Thelia/Type/TypeInterface.php index 642c6d935..99e2f77e0 100755 --- a/core/lib/Thelia/Type/TypeInterface.php +++ b/core/lib/Thelia/Type/TypeInterface.php @@ -22,12 +22,13 @@ /*************************************************************************************/ namespace Thelia\Type; +use Symfony\Component\Validator\ExecutionContextInterface; + /** * * @author Etienne Roudeix * */ - interface TypeInterface { public function getType(); @@ -38,4 +39,5 @@ interface TypeInterface public function getFormType(); public function getFormOptions(); + public function verifyForm($value, ExecutionContextInterface $context); } diff --git a/templates/admin/default/tax-edit.html b/templates/admin/default/tax-edit.html index 07a18a111..2bb0b260e 100644 --- a/templates/admin/default/tax-edit.html +++ b/templates/admin/default/tax-edit.html @@ -88,7 +88,7 @@ {form_tagged_fields form=$form tag='requirements'}
{if $formType == 'choice'}