How to popular a dynamically select or checkbox using Annotations in ZF 2’s Zend Form?

Asked

Viewed 289 times

6

I learned to do this with fixed values, example:

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

However, how I put this option to display data from a database table, such as cities table?

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

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":"---"}))

Solved my problem.

  • knows when the zend will flip blades?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.