简体   繁体   中英

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".

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM