Inheritance: extends ZenValidatorConstraint
 function __construct(Controller $controller, $name)
 {
     $this->currController = $controller;
     $fields = new FieldList(array(TextField::create("FirstName")->setTitle(_t("ContactPage.FIRSTNAME", "First Name"))->addPlaceholder(_t("ContactPage.FIRSTNAMEPLACEHOLDER", "Your First Name"))->setMaxLength(55)->setAttribute("autocomplete", "off"), TextField::create("LastName")->setTitle(_t("ContactPage.LASTNAME", "Last Name"))->addPlaceholder(_t("ContactPage.LASTNAMEPLACEHOLDER", "Your Last Name"))->setMaxLength(55)->setAttribute("autocomplete", "off"), EmailField::create("Email")->setTitle(_t("ContactPage.EMAIL", "Email"))->addPlaceholder(_t("ContactPage.EMAILPLACEHOLDER", "Your Email address"))->setMaxLength(55)->setAttribute("autocomplete", "off"), TextField::create("Phone")->setTitle(_t("ContactPage.PHONE", "Phone"))->addPlaceholder(_t("ContactPage.PHONEPLACEHOLDER", "Your Phone number"))->setMaxLength(55)->setAttribute("autocomplete", "off"), TextareaField::create("Description")->setTitle(_t("ContactPage.DESCRIPTION", "Message"))->addPlaceholder(_t("ContactPage.DESCRIPTIONPLACEHOLDER", "Your Message for us"))->setRows(6), TextField::create("Url")->setTitle("")->addPlaceholder(_t("ContactPage.URL", "Url"))->setMaxLength(55)->setAttribute("autocomplete", "off"), TextareaField::create("Comment")->setTitle("")->addPlaceholder(_t("ContactPage.COMMENT", "Comment"))->setRows(6), HiddenField::create("Ref")->setValue($controller->Title), HiddenField::create("Locale")->setValue($controller->Locale)));
     $actions = new FieldList(FormAction::create('dosave', _t("ContactPage.APPLY", "Send"))->setStyle("success"));
     $validator = ZenValidator::create();
     $validator->addRequiredFields(array('FirstName', 'LastName', 'Email', 'Description'));
     $validator->setConstraint('Email', Constraint_type::create('email'));
     $validator->setConstraint('Description', Constraint_length::create('min', 10));
     parent::__construct($controller, $name, $fields, $actions, $validator);
     if ($this->extend('updateFields', $fields) !== null) {
         $this->setFields($fields);
     }
     if ($this->extend('updateActions', $actions) !== null) {
         $this->setActions($actions);
     }
     // if($this->extend('updateValidator', $requiredFields) !== null) {$this->setValidator($requiredFields);}
     $oldData = Session::get("FormInfo.{$this->FormName()}.data");
     if ($oldData && (is_array($oldData) || is_object($oldData))) {
         $this->loadDataFrom($oldData);
     }
     $this->extend('updateContactInquiryForm', $this);
 }
 public function testAlphanumType()
 {
     $zv = $this->Form()->getValidator();
     $zv->setConstraint('Title', Constraint_type::create('alphanum'));
     // test attributes
     $field = $zv->getConstraint('Title', 'Constraint_type')->getField();
     $this->assertTrue($field->getAttribute('data-parsley-type') == 'alphanum');
     // test valid
     $data['Title'] = '500tests';
     $zv->php($data);
     $this->assertEmpty($zv->getErrors());
     // test invalid
     $data['Title'] = '500 tests + other things';
     $zv->php($data);
     $errors = $zv->getErrors();
     $this->assertTrue($errors[0]['fieldName'] == 'Title');
 }