How to populate a select or checkbox dynamically using annotations in the Zend Form ZF 2?

6

I learned to do this with fixed values, eg:

@Annotation\Type("Zend\Form\Element\Select")
@Annotation\Options({"label":"Cidade"})
@Annotation\Attributes({"options":{"1":"São Paulo","2":"Rio de Janeiro"}})

However, how do I put these options to display data from a database table, such as cities table?

And in the case of a checkbox, would it be the same?

    
asked by anonymous 13.07.2015 / 21:40

1 answer

0

RESOLVED:

@Form\Type("DoctrineModule\Form\Element\ObjectSelect")
@Form\Options({"label":"Pessoa", "target_class":"Pessoa\Entity\Pessoa","find_method":{"name":"findBy","params":{"criteria":{}, "orderBy":{"nome":"ASC"}}},"display_empty_item":true,"empty_item_label":"---"}))

Resolved my issue.

    
16.07.2015 / 15:29