Skip to content

Instantly share code, notes, and snippets.

@tinchodev
Last active August 29, 2015 14:16
Show Gist options
  • Save tinchodev/0dd5c123a4ae717feb57 to your computer and use it in GitHub Desktop.
Save tinchodev/0dd5c123a4ae717feb57 to your computer and use it in GitHub Desktop.
$form = new Varien_Data_Form();
$form->addField('yesno', 'select', array(
'label' => $this->__('Yes or No?'),
'values' => Mage::model('adminhtml/system_config_source_yesnocustom')
->toOptionArray(),
));
$form->addField('custom_value', text, array(
'label' => $this->__('Other'),
));
// Append dependency javascript
$this->setChild('form_after', $this->getLayout()
->createBlock('adminhtml/widget_form_element_dependence')
->addFieldMap('yesno', 'yesno')
->addFieldMap('custom_value', 'custom_value')
->addFieldDependence('custom_value', 'yesno', 2) // 2 = 'Specified'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment