0

I have 2 fields, x and y. If both the fields are same then I want to check save the changes, or else I want to give a message "Value mismatched. Unable to save changes".

system.xml

                      <test1 translate="label">
                            <label>test1</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </test1>
                        <test2 translate="label">
                            <backend_model>test/system_config_backend_test2</backend_model>
                            <label>test2</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </test2>

Backend model class

public function save()
{
    $test2= $this->getValue(); //get the value from our config

    //need to get $test1 also. How to get??
    $test1 = ;
    if($test1 != $test2)
    {
        Mage::throwException('Could not saved');  
    }

    return parent::save();
}

How to get the two values together so that we can compare and check? Thanks in advance!

1 Answer 1

0

I think you should use <frontend_model> in your system.xml so you can add your custom javascript. With this custom javascript you can easily get the value of both field and compare and throw the validation.

Or you can add your custom validation class like this and add your custom class.

1
  • Thanks. But in actual case, i want to validate token id and token access fields which involves api call. Therefore I need to handle this in server level. Commented Dec 7, 2016 at 7:54

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.