I check some validation in my controller. And I want to add error to specific element of my form on failure. My form:
use SymfonyComponentFormFormError;
// ...
$config = new Config();
$form = $this->createFormBuilder($config)
->add('googleMapKey', 'text', array('label' => 'Google Map key'))
->add('locationRadius', 'text', array('label' => 'Location radius (km)'))
->getForm();
// ...
$form->addError(new FormError('error message'));
addError() method adds error to form, not to element. How can I add an error to locationRadius element?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…