We can use 'depends' tag in system.xml in field which we have to show/hide depends on 'yes/no' field.
Below are syntax you can use:
<depends><enabled>1</enabled></depends>
In above syntax 'enabled' is a field with 'yes/no' values.
Above code is for system >> Configuration settings .
To add any field depends on 'yes/no' in product form you can use below code:
$productField = $fieldset->addField('enabled', 'select', array(
'label' => Mage::helper('adminhtml')->__('Enabled'),
'title' => Mage::helper('adminhtml')->__('Enabled'),
'name' => 'enabled',
'options' => array(
0 => Mage::helper('adminhtml')->__('No'),
1 => Mage::helper('adminhtml')->__('Yes'),
),
'onclick' => 'toggleYesNo()',
));
$productField->setAfterElementHtml('
<script>
function toggleFixedShipping() {
$("idToShowHide").toggle();
}
</script>
');
Here 'idToShowHide' id will be show/hide field's ID.
I hope it solves your concern.
Try to set default value as string
'default' => '0'
or empty
'default' => ''
Update
The default values are added when you add new product
for old ones it not affects.
Try to fix that in Product management with mass action
Inside manage products, there is a action called “Update Attributes”. Select all the products that you want to update and then select Update Attributes and add all the new information in.
Best Answer
You need to do code like this :
NOTE: Just confirm product object is load before above code.