I have a form type
class LoginFacebookType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('access_token', 'text', array("constraints" => array(
new Assert\NotBlank(),
new Assert\Length(array("max" => 512))
)))
->add('save', 'submit');
}
public function getName()
{
return 'facebook_login';
}
}
Then, I use it on the controller as:
$facebookLoginForm = $this->createForm(new LoginFacebookType());
$facebookLoginForm->handleRequest($request);
if($facebookLoginForm->isValid())
{
//do something
}
else
{
//Debug form errors
print_r($facebookLoginForm->getErrorsAsString()); die();
}
My questions is: If I made a request with a single param called "facebook_login[access_token]" i get all errors on the controller, like a very big access token, or not passing the csrf_token (This is ok). But if I made a request without any parameters, I get isValid = false, but error list is empty.
I want an "access_token field is required" and "invalid csrf_token" or something like that.
How can I achieve it?