简体   繁体   中英

How can I add a data-attr to each option within an entity field type in Symfony2

I am trying to work out how I can add a data-attr to each of my options within an entity type field. I have looked through the documentation ( http://symfony.com/doc/current/reference/forms/types/entity.html ) and can't seem to find any simple way of adding this.

You cannot add attributes to options in symfony out of the box. But you could look into writing your own custom field type, see: http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html

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