4

I'm creating a register page to create a new user based on FOSUserBundle.

I go this message on the top f the form every time I submit the new user form: This value should not be blank.

Apparently this is a global message and it's not linked to a particular field on my form, so I guess it must be related to any other atribute of my User class.

What mechanism Sf2 offers me in order to figure out what's wrong on my form? I am using Symfony 2.5.0

(I would post more details about my configuration, User class and form... but I really would like to learn how to find this problem on my own)

Thanks in advance, community!

5 Answers5

1

Check out debug toolbar on dev frontend controller, its good debug way for the start

tstr
  • 1,254
  • 20
  • 35
0

This is a tricky error that is hard to track. I was not able to track those type of errors myself, so I searched on Google and SO. I found the answer that explained the problem with my form. It was a validation rule on one of the fields that was not included in the form.

So, in your case that may also be the reason. There is probably a validation rule (most likely NotBlank) on a field that is not included in the form. Just try to disable them one by one to find the filed that is causing this error.

dmnptr
  • 4,258
  • 1
  • 20
  • 19
0

I think you should try printing your $request->get('name_of_your_form'), and after binding it with the form, try printing $form->getData(). Should be enough to be clear about what field causes the issue.

Also make note of validation groups.

reafle
  • 254
  • 1
  • 10
0

Try printing the form errors out as a string using the $form->getErrorsAsString() or the $form->getErrors() methods.

Taken from the source

/**
 * Returns a string representation of all form errors (including children errors).
 *
 * This method should only be used to help debug a form.
 *
 * @param int     $level The indentation level (used internally)
 *
 * @return string A string representation of all errors
 *
 * @deprecated Deprecated since version 2.5, to be removed in 3.0. Use
 *             {@link getErrors()} instead and cast the result to a string.
 */
public function getErrorsAsString($level = 0)
{
    return self::indent((string) $this->getErrors(true, false), $level);
}
qooplmao
  • 17,622
  • 2
  • 44
  • 69
0

you should see the error with more description in the logs of the /_profiler even maybe a SQL error which may lead to the root of the problem.

Rufinus
  • 29,200
  • 6
  • 68
  • 84