Reputation: 109
Can you help me plz i can't find the solution
<?php
/**
* Description of ContactType
*
* @author Thamer
*/
namespace Common\ContactBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Collection;
class ContactType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('name', 'text', array(
'constraints' => array(
new Length(array('min' => 3)),
new NotBlank()
)
)
)
->add('email', 'email', array(
new NotBlank()
)
)
->add('tel', 'number', array(
'constraints' => array(
new Length(array('min' => 8)),
new NotBlank()
)
)
)
->add('message', 'textarea', array(
'constraints' => array(
new Length(array('min' => 10)),
new NotBlank()
)
)
)
->add('recaptcha', 'ewz_recaptcha')
;
}
public function getName() {
return 'common_contact';
}
}
the error is :
The option "0" does not exist. Defined options are: "action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_provider", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "inherit_data", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "max_length", "method", "pattern", "post_max_size_message", "property_path", "read_only", "required", "translation_domain", "trim", "validation_groups", "virtual". 500 Internal Server Error - UndefinedOptionsException
Upvotes: 1
Views: 1018
Reputation: 4539
In your lines:
->add('email', 'email', array(
new NotBlank()
)
)
You are passing in new NotBlank()
, but it should be in a constraints option:
->add('email', 'email', array(
'constraints' => array(
new NotBlank()
)
)
)
Upvotes: 4