条件规则块 - 自定义模块

时间:2013-09-30 04:59:21

标签: magento magento-1.7 magento-1.4 magento-1.5 magento-1.6

我创建了自定义扩展程序,我需要在自定义表单中添加“条件规则选项卡”字段。 显示规则选项卡但无法工作。当我检查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();
}

1 个答案:

答案 0 :(得分: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>