0

我创建了一个自定义扩展,我需要在我的自定义表单中添加一个“条件规则选项卡”字段。规则选项卡已显示但无法工作。当我签入 firebuger 时,将给出以下信息。ReferenceError:未定义 VarienRulesForm 我的代码是

protected function _prepareForm()
{

    $model = Mage::getModel('callforprice/callforprice')->load();

    $form   = new Varien_Data_Form();
    $helper = Mage::helper('callforprice');

    $renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset')
            ->setTemplate('promo/fieldset.phtml')
            ->setNewChildUrl($this->getUrl('callforprice/adminhtml_callforprice/newConditionHtml', array(
                'form'   => 'css_conditions_fieldset',
                'prefix' => 'css',
                'rule'   => base64_encode('callforprice/callforprice_product_rulecss'))));

    $fieldset = $form->addFieldset('css_conditions_fieldset', array(
                'legend' => $this->__('Conditions (leave blank for all products)')
            ))->setRenderer($renderer);

    $rule = Mage::getModel('callforprice/callforprice_product_rulecss');


    $rule->getConditions()->setJsFormObject('css_conditions_fieldset');
    $rule->getConditions()->setId('css_conditions_fieldset');

    $rule->setForm($fieldset);
    if ($model->getData('conditions_serialized') && is_array($model->getData('conditions_serialized')->getData('conditions'))) {
        $conditions = $model->getData('conditions_serialized')->getData('conditions');
        $rule->getConditions()->loadArray($conditions, 'css');
        $rule->getConditions()->setJsFormObject('css_conditions_fieldset');
    }

    $fieldset->addField('css_conditions', 'text', array(
        'name'     => 'css_conditions',
        'label'    => $this->__('Apply To'),
        'title'    => $this->__('Apply To'),
        'required' => true,
    ))->setRule($rule)->setRenderer(Mage::getBlockSingleton('rule/conditions'));

    $form->setValues($model->getData());
    $this->setForm($form);


    return parent::_prepareForm();
}
4

1 回答 1

1

尝试使用 css 加载所有 js 以获取规则。试试这个

  <default>
        <reference name="head">
            <action method="addItem"><type>js</type><name>extjs/ext-tree.js</name><params/></action>
            <action method="addItem"><type>js</type><name>extjs/fix-defer.js</name><params/></action>
            <action method="addItem"><type>js</type><name>extjs/ext-tree-checkbox.js</name><params/></action>
               <action method="addItem"><type>js</type><name>mage/adminhtml/rules.js</name><params/></action>
            <action method="addItem"><type>js_css</type><name>extjs/resources/css/ext-all.css</name><params/></action>
        </reference>
    </default>
于 2013-09-30T06:18:00.703 回答