Erstellen Sie eine Dropdown-Liste in Zend Framework 2

Ich weiß, dass dies viel grundlegender klingt, dennoch möchte ich meine Frage posten, da sie sich auf Zend Framework 2 bezieht. Ich kenne dieses Formular aus dem Zend-Beispielmodul

namespace Album\Form;

use Zend\Form\Form;

class AlbumForm extends Form
{
    public function __construct($name = null)
    {
        // we want to ignore the name passed
        parent::__construct('album');
        $this->setAttribute('method', 'post');
        $this->add(array(
            'name' => 'id',
            'attributes' => array(
                'type'  => 'hidden',
            ),
        ));
        $this->add(array(
            'name' => 'artist',
            'attributes' => array(
                'type'  => 'text',
            ),
            'options' => array(
                'label' => 'Artist',
            ),
        ));
        $this->add(array(
            'name' => 'title',
            'attributes' => array(
                'type'  => 'text',
            ),
            'options' => array(
                'label' => 'Title',
            ),
        ));
        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                'type'  => 'submit',
                'value' => 'Go',
                'id' => 'submitbutton',
            ),
        ));
    }
}

Und das nennt man so

<?php
$form = $this->form;
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();

echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('title'));
echo $this->formRow($form->get('artist'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();

Wie kann ich eine Dropdown-Liste für das Künstlerfeld hinzufügen, in dem die Liste in einem assoziativen Array gespeichert ist? Seit ich in Zend Framework 2 bin, wollte ich die Vorschläge von den Experten. Ich bin gefolgtdieser vorherige Beitrag aber es war mir etwas unklar.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage