Question

I have an admin form with following field

$author = Mage::helper('blog/post')->getDefaultAuthorId();

    $fieldset->addField('post_author', 'select', array(
        'label' => Mage::helper('sprung_blog')->__('Author'),
        'name'  => 'post_author',
        'required'  => true,
        'class' => 'required-entry',
        'value' => $author,
        'values'=> Mage::getModel('sprung_blog/post_attribute_source_postauthor')->getAllOptions(true),
    ));

Postauthor.php file contains following

public function getAllOptions($withEmpty = true, $defaultValues = false){

$collection = Mage::getModel('blog/author')->getCollection();

$options = array(array('value'=>'', 'label'=>'Please Select Author'));

foreach ($collection as $cat){

    $options[] = array('value'=>$cat['entity_id'],'label'=>$cat['author_name']);
}   
return $options;

}

Here, I have one author as selected default from admin configuration. So when i add a new post , "post_author" field i need to display the default user id as selected. After setting 'value' also its not showing as selected in admin form.Please help

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top