Protected Member Functions | |
_prepareForm () |
Definition at line 35 of file Form.php.
_prepareForm | ( | ) | [protected] |
Prepare form before rendering HTML
Check is single store mode
Reimplemented from Mage_Adminhtml_Block_Widget_Form.
Definition at line 37 of file Form.php.
00038 { 00039 $review = Mage::registry('review_data'); 00040 $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue()); 00041 $customer = Mage::getModel('customer/customer')->load($review->getCustomerId()); 00042 $statuses = Mage::getModel('review/review') 00043 ->getStatusCollection() 00044 ->load() 00045 ->toOptionArray(); 00046 00047 $form = new Varien_Data_Form(array( 00048 'id' => 'edit_form', 00049 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'ret' => Mage::registry('ret'))), 00050 'method' => 'post' 00051 )); 00052 00053 $fieldset = $form->addFieldset('review_details', array('legend' => Mage::helper('review')->__('Review Details'), 'class' => 'fieldset-wide')); 00054 00055 $fieldset->addField('product_name', 'note', array( 00056 'label' => Mage::helper('review')->__('Product'), 00057 'text' => '<a href="' . $this->getUrl('*/catalog_product/edit', array('id' => $product->getId())) . '" onclick="this.target=\'blank\'">' . $product->getName() . '</a>' 00058 )); 00059 00060 if ($customer->getId()) { 00061 $customerText = Mage::helper('review')->__('<a href="%1$s" onclick="this.target=\'blank\'">%2$s %3$s</a> <a href="mailto:%4$s">(%4$s)</a>', 00062 $this->getUrl('*/customer/edit', array('id' => $customer->getId(), 'active_tab'=>'review')), 00063 $this->htmlEscape($customer->getFirstname()), 00064 $this->htmlEscape($customer->getLastname()), 00065 $this->htmlEscape($customer->getEmail())); 00066 } else { 00067 if (is_null($review->getCustomerId())) { 00068 $customerText = Mage::helper('review')->__('Guest'); 00069 } elseif ($review->getCustomerId() == 0) { 00070 $customerText = Mage::helper('review')->__('Administrator'); 00071 } 00072 } 00073 00074 $fieldset->addField('customer', 'note', array( 00075 'label' => Mage::helper('review')->__('Posted By'), 00076 'text' => $customerText, 00077 )); 00078 00079 $fieldset->addField('summary_rating', 'note', array( 00080 'label' => Mage::helper('review')->__('Summary Rating'), 00081 'text' => $this->getLayout()->createBlock('adminhtml/review_rating_summary')->toHtml(), 00082 )); 00083 00084 $fieldset->addField('detailed_rating', 'note', array( 00085 'label' => Mage::helper('review')->__('Detailed Rating'), 00086 'required' => true, 00087 'text' => '<div id="rating_detail">' . $this->getLayout()->createBlock('adminhtml/review_rating_detailed')->toHtml() . '</div>', 00088 )); 00089 00090 $fieldset->addField('status_id', 'select', array( 00091 'label' => Mage::helper('review')->__('Status'), 00092 'required' => true, 00093 'name' => 'status_id', 00094 'values' => Mage::helper('review')->translateArray($statuses), 00095 )); 00096 00097 /** 00098 * Check is single store mode 00099 */ 00100 if (!Mage::app()->isSingleStoreMode()) { 00101 $fieldset->addField('select_stores', 'multiselect', array( 00102 'label' => Mage::helper('review')->__('Visible In'), 00103 'required' => true, 00104 'name' => 'stores[]', 00105 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm() 00106 )); 00107 $review->setSelectStores($review->getStores()); 00108 } 00109 else { 00110 $fieldset->addField('select_stores', 'hidden', array( 00111 'name' => 'stores[]', 00112 'value' => Mage::app()->getStore(true)->getId() 00113 )); 00114 $review->setSelectStores(Mage::app()->getStore(true)->getId()); 00115 } 00116 00117 $fieldset->addField('nickname', 'text', array( 00118 'label' => Mage::helper('review')->__('Nickname'), 00119 'required' => true, 00120 'name' => 'nickname' 00121 )); 00122 00123 $fieldset->addField('title', 'text', array( 00124 'label' => Mage::helper('review')->__('Summary of review'), 00125 'required' => true, 00126 'name' => 'title', 00127 )); 00128 00129 $fieldset->addField('detail', 'textarea', array( 00130 'label' => Mage::helper('review')->__('Review'), 00131 'required' => true, 00132 'name' => 'detail', 00133 'style' => 'height:24em;', 00134 )); 00135 00136 $form->setUseContainer(true); 00137 $form->setValues($review->getData()); 00138 $this->setForm($form); 00139 return parent::_prepareForm(); 00140 }