I have defined the following variable within an entity in my application. I have this, among other fields that can be updated via a form interface and I wish to be able to check and uncheck this box on that form.
I can check the box and submit the form fine, but it seems that when I uncheck the box, I can't submit the form. It gives me a Please check this box if you want to proceed
.
/**
* @var boolean $updatesNeeded
*
* @ORM\Column(name="updates_needed", type="boolean", nullable=false)
*/
private $updatesNeeded;
I tried changing nullable=false
to nullable=true
and updating the schema, but it doesn't seem to work. Any ideas would be much appreciated.
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
class BlahType extends AbstractType
{
/**
* @param \Symfony\Component\Form\FormBuilder $builder
* @param array $options
*/
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('stuff')
->add('updatesNeeded', 'choice', array('required' => false))
->add('anothervar');
}
}
This error is because the input is marked with the HTML5 attribute required="required"
. In your form type you can disable this by setting the required
option to false on this checkbox.
$builder->add('updatesNeeded', 'choice', array('required' => false));
http://symfony.com/doc/current/book/forms.html#book-forms-html5-validation-disable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With