Author - Robert Popovic

Founder and Technical Director of LERO9, a web agency specializing in Magento and WordPress design and development.

I launched Magebase in April, 2010 and am its editor and contributor. My main topics of interest are Magento development, customization and how to get the most out of Magento with the least amount of headache.

More Info » Follow me on Twitter »

Reader Comments (7)

  1. Damián
    September 5, 2011 at 5:14 pm /

    Why not to use instead?

    Reply
  2. Damián
    September 5, 2011 at 5:16 pm /

    Last chance and no more coffee.
    You can use the depends node into the system.xml.

    Reply
  3. MagePsycho
    September 5, 2011 at 5:58 pm /

    Yes

    <depends/>

    allows you specify that your configuration field should only be displayed when another confgiruation field in the same group has a specific value.
    But note that this node is available on Magento version >= 1.4.x

    Reply
  4. Steve
    December 7, 2011 at 8:58 am /

    Simple dependencies can be done anywhere in forms by hijacking the same block that the system.xml config uses. Just add the Mage_Adminhtml_Widget_Form_Element_Dependence block to your layout and use its addFieldMap() to map element IDs to a field and addFieldDependence() to set up the dependencies. For example, on a form that shows FTP login information fields only if FTP is selected as a source, I do:

    $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence'))
    	->addFieldMap('source_type', 'source_type')
    	->addFieldMap('ftp_server', 'ftp_server')
    	->addFieldMap('ftp_user', 'ftp_user')
    	->addFieldMap('ftp_pass', 'ftp_pass')
    	->addFieldDependence('ftp_server', 'source_type', 'ftp')
    	->addFieldDependence('ftp_user', 'source_type', 'ftp')
    	->addFieldDependence('ftp_pass', 'source_type', 'ftp');
    Reply

Add a Comment & Join the Discussion

Insert small snippets of code by using [code]{your_code_here}[/code]
For larger code blocks please use http://pastebin.com and paste your link.

You may also use the following HTML in your comment: <a href="" title=""> <abbr title="">
<acronym title=""> <blockquote cite=""> <cite> <em> <strike> <strong>