Magento Custom module - how to add custom select box with parent categories -
i wrote module have own menu bar, rather using categories menu bar.
so, here want show added menus while adding new menu in tab/form.php in custom menu module. how can show of existing menu names dropdown/options list on form. here code used have menu form.
$form = new varien_data_form(); $this->setform($form); $fieldset = $form->addfieldset('menu_form', array('legend'=>mage::helper('menu')->__('menu information'))); $note = "name of menu"; $fieldset->addfield('title', 'text', array( 'label' => mage::helper('menu')->__('menu name'), 'class' => 'required-entry', 'required' => true, 'note' => $note, 'name' => 'title', )); $note = "menu level"; $fieldset->addfield('level', 'select', array( 'label' => mage::helper('menu')->__('menu level'), 'name' => 'level', 'note' => $note, 'values' => array( array( 'value' => 1, 'label' => mage::helper('menu')->__('level 1'), ), array( 'value' => 2, 'label' => mage::helper('menu')->__('level 2'), ), ), )); $model = mage::registry('menu'); $fieldset->addfield('parent', 'text', array( 'name' => 'conditions', 'label' => mage::helper('menu')->__('parent menu'), 'title' => mage::helper('menu')->__('parent menu'), 'required' => false, 'note' => $note, ))->setrule($model)->setrenderer(mage::getblocksingleton('rule/conditions')); $fieldset->addfield('target', 'select', array( 'label' => mage::helper('menu')->__('open in new window'), 'name' => 'target', 'values' => array( array( 'value' => "_blank", 'label' => mage::helper('menu')->__('yes'), ), array( 'value' => "_self", 'label' => mage::helper('menu')->__('no'), ), ), )); $fieldset->addfield('status', 'select', array( 'label' => mage::helper('menu')->__('status'), 'name' => 'status', 'values' => array( array( 'value' => 1, 'label' => mage::helper('menu')->__('enabled'), ), array( 'value' => 2, 'label' => mage::helper('menu')->__('disabled'), ), ), )); $note = "menu links page. baseurl(<b>".str_ireplace("index.php/","",mage::getbaseurl())."</b>) added dynamically, please add new page refrence alone"; $fieldset->addfield('menulink', 'text', array( 'label' => mage::helper('menu')->__('url'), 'required' => true, 'class' => 'required-entry', 'note' => $note, 'name' => 'menulink', )); $fieldset->addfield('position', 'select', array( 'label' => mage::helper('menu')->__('position'), 'name' => 'position', 'values' => array( array( 'value' => 1, 'label' => mage::helper('menu')->__('top 1'), ), array( 'value' => 2, 'label' => mage::helper('menu')->__('top 2'), ), ), )); if ( mage::getsingleton('adminhtml/session')->getmenudata() ) { $form->setvalues(mage::getsingleton('adminhtml/session')->getmenudata()); mage::getsingleton('adminhtml/session')->setmenudata(null); } elseif ( mage::registry('menu_data') ) { $form->setvalues(mage::registry('menu_data')->getdata()); } return parent::_prepareform();
in want show added menus under parent menu option. should write in model class can have drop down list show them all, , after adding should added database.
please me, struggling here.
you can adding these lines.
it show added menus dropdown list can choose of them parent menu current item.
$_menus = mage::getsingleton('menus/menus')->getcollection(); foreach($_menus $item) { if($item->getparent == null){ $_menuitems[] = array( 'value' => $item->getid(), 'label' => $item->gettitle(), ); } } $note = "choose parent menus item"; $fieldset->addfield('parent', 'select', array( 'name' => 'parent', 'label' => mage::helper('menus')->__('parent menu'), 'title' => mage::helper('menus')->__('parent menu'), 'required' => false, 'note' => $note, 'class' => 'hideit', 'values' => $_menuitems, ));
Comments
Post a Comment