Answer the question
In order to leave comments, you need to log in
Form validation with custom flash messages Symfony2?
How to properly validate a form?
What we have:
There is an essence
class Product
{
private $product;
/**
* Set product
*
* @param string $product
*
* @return Product
*/
public function setProduct($product)
{
$this->product = $product;
return $this;
}
/**
* Get product
*
* @return string
*/
public function getProduct()
{
return $this->product;
}
}
class ProductType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
//...
$builder
->add('product')
//...
->add('save', SubmitType::class);
));
}
//...
}
//App/NameBundle/Resource/config/validation.yml
App\EducationBundle\Entity\Product:
properties:
product:
- Length: { min: 5, minMessage: 'Каши не ел? Добавь еще символов!'}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question