Here i working custom form with custom select box in magento.I need to assign Custom select box with option value attributes and option values .
Here i working custom form sample code:
$fabrics = Mage::getModel('magentostudy_fabrics/fabrics')->getCollection();
$fabricval[] = "Please Select";
$fabricvals[] = "0";
// $collection->addAttributeToSelect('news_id'); //retrieve only product name (optimising SQL)
foreach ($fabrics as $fabric) //loop for getting products
{
$fabricval[] = $fabric->getTitle();
$fabricvals[] = $fabric->getNews_id();
}
$fieldset->addField('fabricslist', 'select', array(
'name' => 'fabricslist',
'label' => Mage::helper('bulk_uploader')->__('Select Fabrics List'),
'title' => Mage::helper('bulk_uploader')->__('Select Fabrics List'),
'required' => true,
'onclick' => "",
'onchange' => "",
'value' => $fabricvals,
'values' =>$fabricval,
'disabled' => $isElementDisabled,
'readonly' => false,
'after_element_html' => '<small>choose Category list</small>',
'tabindex' => 1
));
Here 'value' => $fabricval
got wrong values.For example i have News_ID 1,3,5 respectively.But i results only 1,2,3 respectively.How to assign value
attributes in select box
for example I need select box sample function
<select>
<option value='1'>sample1</option>
<option value='3'>sample2</option>
<option value='5'>sample3</option>
</select>
How to assign select box option value attributes in magento?