/**
* Create Add Artist Form.
*
* @return Zend_Form
*/
private function getAddArtistForm()
{
$form = new Zend_Form();
$form->setAction("saveArtist");
$form->setMethod("post");
$form->setName("addartist");
//Create artist name text field.
$artistNameElement = new Zend_Form_Element_Text('artistName');
$artistNameElement->setLabel("Artist Name:");
//Create genres select menu
$genres = array("multiOptions" => array
(
"electronic" => "Electronic",
"country" => "Country",
"rock" => "Rock",
"r_n_b" => "R & B",
"hip_hop" => "Hip-Hop",
"heavy_metal" => "Heavy-Metal",
"alternative_rock" => "Alternative Rock",
"christian" => "Christian",
"jazz" => "Jazz",
"pop" => "Pop"
));
$genreElement = new Zend_Form_Element_Select('genre', $genres);
$genreElement->setLabel("Genre:");
$genreElement->setRequired(true);
//Create favorite radio buttons.
$favoriteOptions = array("multiOptions" => array
(
"1" => "yes",
"0" => "no"
));
$isFavoriteListElement = new Zend_Form_Element_Radio('isFavorite',
$favoriteOptions);
$isFavoriteListElement->setLabel("Add to Favorite List:");
$isFavoriteListElement->setRequired(true);
//Create Rating raio button
$ratingOptions = array("multiOptions" => array
(
"1" => "1",
"2" => "2",
"3" => "3",
"4" => "4",
"5" => "5"
));
$ratingElement = new Zend_Form_Element_Radio('rating', $ratingOptions);
$ratingElement->setLabel("Rating:");
$ratingElement->setRequired(true)->addValidator(new Zend_Validate_Alnum(false));
//Create submit button
$submitButton = new Zend_Form_Element_Submit("submit");
$submitButton->setLabel("Add Artist");
//Add Elements to form
$form->addElement($artistNameElement);
$form->addElement($genreElement);
$form->addElement($isFavoriteListElement);
$form->addElement($ratingElement);
$form->addElement($submitButton);
return $form;
}
It shows all items twice and inconsistent labels and it also doesn't fill the select box.
On Tue, Nov 17, 2009 at 5:30 PM, Jigal sanders <jigalroecha@gmail.com> wrote:
Hello overyone.
I'm trying to fill a Zend_Form_Element_Select box with an array but it stays empty on the screen.This is my code:// create artist name text field$artistNameElement = new Zend_Form_Element_Text('artistName');$artistNameElement->setLabel("Artist name: ");$genres = array("multiOptions" => array("electronic" =>"Electronic","country" => "Country","rock" =>"Rock","r_n_b" =>"R & B","hip_hop" => "Hip-Hop","heavy_metal" =>"Heavy-Metal","alternative_rock" =>"Alternative Rock","jazz" =>"Jazz","pop" =>"Pop"));$genreElement = new Zend_Form_Element_Select('genre', $genres);$genreElement->setLabel("Genre:");$genreElement->setRequired(true);What is going wrong?Thanks,j sanders
--
Met vriendelijke groet,
Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489
没有评论:
发表评论