Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html5 number type 'min' and 'max' implementation in symfony2

Please is there a way of implementing HTML5 number type 'min' and 'max' in symfony2?

I have try this:

->add('min_age', 'integer', array ('min' => '18', 'max' => '90' ))

and getting error "The options "max", "min" do not exist".

like image 473
jimcool Avatar asked Jun 09 '14 10:06

jimcool


1 Answers

As these are attributes of the field element, do the following:

->add('min_age', 'integer', array('attr' => array(
    'min' => '18',
    'max' => '90',
)));

It will render the form element with min and max attributes.

like image 58
VisioN Avatar answered Sep 21 '22 17:09

VisioN