Example – Admin notification Severity values taken as in dropdown.

Step – 1) Add Fields in system.xml file

<fields>
<severity translate=”label”>
<label>Display Settings</label>
<frontend_type>multiselect</frontend_type>
<source_model>weboffice_magenotifier/system_config_source_view</source_model>
<sort_order>40</sort_order>
<show_in_default>1</show_in_default>
</severity>
</fields>

Step – 2) Create file for multiselect options

Weboffice/MageNotifier/Model/System/Config/Source/View.php

<?php

class Weboffice_MageNotifier_Model_System_Config_Source_View
{
/**
* Options getter
*
* @return array
*/

// SEVERITY_CRITICAL, SEVERITY_MAJOR, SEVERITY_MINOR, SEVERITY_NOTICE

public function toOptionArray()
{
return array(
array(‘value’ => 1, ‘label’ => Mage::helper(‘weboffice_magenotifier’)->__(‘Critical’)),
array(‘value’ => 2, ‘label’ => Mage::helper(‘weboffice_magenotifier’)->__(‘Major’)),
array(‘value’ => 3, ‘label’ => Mage::helper(‘weboffice_magenotifier’)->__(‘Minor’)),
array(‘value’ => 4, ‘label’ => Mage::helper(‘weboffice_magenotifier’)->__(‘Notice’)),
);
}

/**
* Get options in “key-value” format
*
* @return array
*/
public function toArray()
{
return array(
1 => Mage::helper(‘weboffice_magenotifier’)->__(‘Critical’),
2 => Mage::helper(‘weboffice_magenotifier’)->__(‘Major’),
3 => Mage::helper(‘weboffice_magenotifier’)->__(‘Minor’),
4 => Mage::helper(‘weboffice_magenotifier’)->__(‘Notice’),
);
}

}

Advertisements