Magento - 如何在自定义Adminhtml表单中设置自定义变量

时间:2015-06-16 16:11:09

标签: php magento

我正在开发自定义Magento扩展程序。版本:1.9.0.1。

我有一个自定义的Adminhtml表单,这里是:

custom adminhtml form

这是表格代码:

<?php

class VivasIndustries_SmsNotification_Block_Adminhtml_Sms_Status_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
    {


        protected function _prepareForm()
            {
            $form = new Varien_Data_Form(array(
                                    'id' => 'edit_form',
                                    'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
                                    'method' => 'post',
                                 ));

                $fieldset = $form->addFieldset('edit_form', array('legend'=>Mage::helper('smsnotification')->__('SMS Information')));

                $statuses = Mage::getResourceModel('sales/order_status_collection')
                    ->toOptionArray();

                $statuses = array_merge(array('' => ''), $statuses);

                $fieldset->addField('state', 'select',
                    array(
                        'name'      => 'state',
                        'label'     => Mage::helper('smsnotification')->__('Order Status'),
                        'class'     => 'required-entry',
                        'values'    => $statuses,
                        'required'  => true,
                    )
                );

                $fieldset->addField('smstext', 'textarea', array(
                          'label'     => Mage::helper('smsnotification')->__('SMS Text'),
                          'class'     => 'required-entry',
                          'required'  => true,
                          'name'      => 'smstext',
                          'onclick' => "",
                          'onchange' => "",
                          'after_element_html' => '<br><small>SMS text must <b>NOT</b> be longer then 160 characters!</small>',
                          'tabindex' => 1
                        ));






                if ( Mage::getSingleton('adminhtml/session')->getsmsnotificationData() )
                    {
                        $form->setValues(Mage::getSingleton('adminhtml/session')->getsmsnotificationData());
                        Mage::getSingleton('adminhtml/session')->setsmsnotificationData(null);
                    } elseif ( Mage::registry('smsnotification_data') ) {
                        $form->setValues(Mage::registry('smsnotification_data')->getData());
                    }
                // Add these two lines


                $form->setUseContainer(true);
                $this->setForm($form);

                ////

                return parent::_prepareForm();
            }
    }

我使用此代码从订单中获取客户名称:

$CustomerName = $observer->getOrder()->getBillingAddress()->getName();

如何检查整个文本,是否找到CustomVariable_CustomerName将其替换为真实的客户名称?

0 个答案:

没有答案