Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //helper functions
- public function resetData($model,$id = null) {
- if(is_null($id)){
- $data = $model->getCollection()
- ->allTables()
- ->getData();
- } else {
- $data = $model->getCollection()
- ->allTables()
- ->addFieldToFilter('coupon_id', array('eq'=>$id))
- ->getData();
- }
- Mage::getSingleton('adminhtml/session')->setCsmData($data);
- }
- public function prepareAcctForm($form, $model, $id = null) {
- $this->resetData($model,$id);
- $data = Mage::getSingleton('adminhtml/session')->getCsmData();
- $data = $data[0];
- $form->setDataObject($data);
- return array('data' => $data,'form' => $form);
- }
- //Form.php
- $p = Mage::helper('csm')->prepareAcctForm($form,Mage::getModel('csm/csm'),$this->getRequest()->getParam('id'));
- $form = $p['form'];
- $data = $p['data'];
- /* insert fields */
- $this->setForm($form);
- /*this used to be $form->setValues($data); and it didn't work. Changed to add and it did.
- $form->addValues($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement