1

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

1
  • It often happens when setting an unaccepted key in $options parameter. Did you do something with it? Commented Aug 12, 2015 at 20:37

1 Answer 1

4

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()
          )
       )
    )
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.