1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_System_Variable_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
35: {
36: 37: 38: 39: 40:
41: public function getVariable()
42: {
43: return Mage::registry('current_variable');
44: }
45:
46: 47: 48: 49: 50:
51: protected function _prepareForm()
52: {
53: $form = new Varien_Data_Form(array(
54: 'id' => 'edit_form',
55: 'action' => $this->getData('action'),
56: 'method' => 'post'
57: ));
58:
59: $fieldset = $form->addFieldset('base', array(
60: 'legend'=>Mage::helper('adminhtml')->__('Variable'),
61: 'class'=>'fieldset-wide'
62: ));
63:
64: $fieldset->addField('code', 'text', array(
65: 'name' => 'code',
66: 'label' => Mage::helper('adminhtml')->__('Variable Code'),
67: 'title' => Mage::helper('adminhtml')->__('Variable Code'),
68: 'required' => true,
69: 'class' => 'validate-xml-identifier'
70: ));
71:
72: $fieldset->addField('name', 'text', array(
73: 'name' => 'name',
74: 'label' => Mage::helper('adminhtml')->__('Variable Name'),
75: 'title' => Mage::helper('adminhtml')->__('Variable Name'),
76: 'required' => true
77: ));
78:
79: $useDefault = false;
80: if ($this->getVariable()->getId() && $this->getVariable()->getStoreId()) {
81: $useDefault = !((bool)$this->getVariable()->getStoreHtmlValue());
82: $this->getVariable()->setUseDefaultValue((int)$useDefault);
83: $fieldset->addField('use_default_value', 'select', array(
84: 'name' => 'use_default_value',
85: 'label' => Mage::helper('adminhtml')->__('Use Default Variable Values'),
86: 'title' => Mage::helper('adminhtml')->__('Use Default Variable Values'),
87: 'onchange' => 'toggleValueElement(this);',
88: 'values' => array(
89: 0 => Mage::helper('adminhtml')->__('No'),
90: 1 => Mage::helper('adminhtml')->__('Yes')
91: )
92: ));
93: }
94:
95: $fieldset->addField('html_value', 'textarea', array(
96: 'name' => 'html_value',
97: 'label' => Mage::helper('adminhtml')->__('Variable HTML Value'),
98: 'title' => Mage::helper('adminhtml')->__('Variable HTML Value'),
99: 'disabled' => $useDefault
100: ));
101:
102: $fieldset->addField('plain_value', 'textarea', array(
103: 'name' => 'plain_value',
104: 'label' => Mage::helper('adminhtml')->__('Variable Plain Value'),
105: 'title' => Mage::helper('adminhtml')->__('Variable Plain Value'),
106: 'disabled' => $useDefault
107: ));
108:
109: $form->setValues($this->getVariable()->getData())
110: ->addFieldNameSuffix('variable')
111: ->setUseContainer(true);
112:
113: $this->setForm($form);
114: return parent::_prepareForm();
115: }
116:
117: }
118: