Cakephp dropdown selected value not coming correct

2019-08-10 09:39发布

问题:

I'm having error in setting up a drop down selected value returned from a controller in firefox only.. Im using cakephp 1.3.

It comes right when i first time load the pages but if i change the drop down value and refresh the page the value doesnt changed. It should be the one coming from controller.

But when i press ctrl+f5 the right value is showed up.

I guess it is something to do with the browser cache. Im not having this problem in google chrome.

im setting the value of the dropdown with selected value using this code

echo $this->Form->input('to_country_code',array(
            'options'=>$countries,
            'id'=>'to_country_code',
            'label' => __('Country',true),
            //'selected'=>$selectedCountryCode
            'div' => false,
            'default'=>$selectedToCountryCode
            )
        );

Any answers would be highly appreciated.

回答1:

Firefox will retain your form values when you refresh the page, no doubt it will reflect the changes. Its only to help users for not to loose the input which is already entered. But if you click on the address bar and press enter then entire page will be loaded with initial values.

Its not a Cakephp issue.



回答2:

This is something particular to Firefox, not CakePHP. It caches some of the form data unless you hard refresh.