3

I am working in Magento 1.9 , I have made a multiselect field in system.xml . When i select some fields in multiselect and click on save config it works fine , but when i did not select any field it should save empty string in DB but it stores the previous values . see my code in system.xml.

<onerateserviceOptions>
                            <label>One Rate </label>
                            <frontend_type>multiselect</frontend_type>
                            <source_model>FedExSmall/Source_FedExSmallIoneRateServices</source_model>
                            <sort_order>12</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </onerateserviceOptions>

Note : That issue only occur in case when i did not select any field . Looking for kind help . Thank You in advance.

3
  • Can you post your system.xml to your question? Sep 13, 2018 at 13:56
  • Please post the full xml file. Sep 13, 2018 at 14:01
  • Dear xml file is too long , it will be difficult to upload . Sep 13, 2018 at 14:09

2 Answers 2

4

You need to add tag <can_be_empty> to allow the field storing empty value. So your field should be like this:

<onerateserviceOptions>
    <label>One Rate </label>
    <frontend_type>multiselect</frontend_type>
    <source_model>FedExSmall/Source_FedExSmallIoneRateServices</source_model>
    <sort_order>12</sort_order>
    <can_be_empty>1</can_be_empty>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</onerateserviceOptions>
1
  • Happy to help :)
    – leogent
    Sep 14, 2018 at 7:58
-1

Just create function , that will be tranfer "null" to some data or text (for exmpl - "no atribute") .

If (....no selected values )
{
  setValue ...
}

Etc..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.