Multiselect Bug in the backend

In Magento version < 1.7.0.0-alpha1 it is not possible to empty a multiselect.

In the adminbackend in Magento is a bug, which prevents a multiselect to become empty.

<select>

A <select> element is not submited, if no option is selected. To submit a value you need to render a <input type="hidden" /> element before it. This way, the variable is set in $_GET or $_POST and may be overwritten by the <select>.

Bug in magento

This <input type="hidden" /> is not rendered before Version 1.7.0.0-alpha1.

Fix

Thanks to this thread I found a quick, good fix (as magento fixed it in versions > 1.7.0.0-alpha1):

// app/code/core/Mage/Adminhtml/Block/Widget/Form.php:203
} else if ($inputType == 'multiselect') {
	$element->setValues($attribute->getSource()->getAllOptions(false, true));
	$element->setCanBeEmpty(true); // add this line

The line number is from version 1.7.0.2