zend-form2

How to get data from different model for select?

北城以北 提交于 2019-11-28 12:09:57
问题 I have form with some attributes: class ToraForm extends Form { public function __construct($name = null) { parent::__construct('tora'); $this->setAttribute('method', 'post'); $this->add(array( 'name' => 'id', 'attributes' => array( 'type' => 'hidden', ), )); $this->add(array( 'name' => 'name', 'attributes' => array( 'type' => 'text', 'required' => true, ), 'options' => array( 'label' => 'name', ), )); } but I want add drop-down list with data taken from another model. How to do it? 回答1:

How to translate form labels in Zend Framework 2?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 10:12:18
I'm not getting it !.. Can please someone explain, how to translate form labels? A simple example would be great. Thank you in advance! class Search\Form\CourseSearchForm ... class CourseSearchForm extends Form { ... public function __construct(array $cities) { parent::__construct('courseSearch'); ... $this->add(array( 'name' => 'city', 'type' => 'Zend\Form\Element\Select', 'options' => array( 'label' => 'Stadt', 'value_options' => $this->cities, 'id' => 'searchFormCity', ), )); ... } } view script /module/Search/view/search/search/search-form.phtml <?php echo $this->form()->openTag($form); ?>