System Config Multiselect default all selected
Use DataScript to store data in config module.
How to create data script
http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/
In datascript simply call the core config module and save your data
$myDynamicValue = '1,2,3';
Mage::getConfig()->saveConfig('section/group/field', $myDynamicValue, 'default', 0);
I give multiselect example.
<fields>
<view_style translate="label">
<label>Display Settings</label>
<frontend_type>multiselect</frontend_type>
<source_model>yourmodule/system_config_source_view</source_model>
<sort_order>40</sort_order>
<show_in_default>1</show_in_default>
</view_style>
</fields>
create one file for multiselect option in your module in this path
your_namespace/yourmodel/Model/System/Config/Source/View.php
Add below code in your View.php
class YourNamespace_YourModule_Model_System_Config_Source_View
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return array(
array('value' => 0, 'label' => Mage::helper('adminhtml')->__('Data1')),
array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Data2')),
array('value' => 2, 'label' => Mage::helper('adminhtml')->__('Data3')),
);
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
return array(
0 => Mage::helper('adminhtml')->__('Data1'),
1 => Mage::helper('adminhtml')->__('Data2'),
3 => Mage::helper('adminhtml')->__('Data3'),
);
}
}
<default>
<mytab>
<mysection>
<attributes><!-- ***WHAT SHOULD I WRITE HERE*** --></attributes>
</mysection>
</mytab>
</default>
You should use the comma separated keys of your options array.
eg
<default>
<mytab>
<mysection>
<attributes>0,1,3</attributes>
</mysection>
</mytab>
</default>
Selects all three options by default.