• Resolved William Millitt

    (@william-millitt)


    Hi,

    I am currently using your plugin for a site and have found that if someone misses a required field the following happens.

    * Red box appears stating what field that they have missed, but then the drop down options seem to vanish.

    I just wondered if this is something that can be fixed at all without refreshing the screen and filling out all the fields again.

    Cheers

    Will

    https://ww.wp.xz.cn/plugins/contact-forms/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Having just gone at this for several hours for a client I can confirm that you’re not the only one with this problem.

    The issue is that the plugin doesn’t properly serialize some option element subclasses, so that when the form is stored in the session the available options for a drop-down aren’t saved with it.

    This issue will only appear if ajax submission breaks or is disabled for some reason.

    If there is a repo I can commit my “fix” to I will gladly provide you (and indeed Cimatti) with updated code that works around at least this specific case. I’ve not taken the time yet to see if other form elements might also succumb to this issue.

    Plugin Author cimatti

    (@cimatti)

    Hi,

    I always use the ajax submit, so maybe I have missed this odd bug.

    @hanra can you just post here the patch, so I can check it out and integrate it? I may give you credits in the changelog in the form you prefer

    Since the issue was with serialization of the form elements my solution was to override the __sleep method on the Select class to include the options.

    Now I think about it, the better solution is to add this to the OptionElement class in PFBC/OptionElement.php:

    public function __sleep() {
    	$fields = parent::__sleep();
    	array_push($fields, "options");
    	return $fields;
    }

    More than happy to get credits if you use this 🙂

    Tom

    Plugin Author cimatti

    (@cimatti)

    Ah, wait, now I remember why I created the class classes/Element/Select.php about 5 months ago and included it in the version I released 2 days ago. Now I use this class for selects, and the only difference is that it extends classes/Element/OptionElement.php that already serializes the $options array.

    Things in folder PFBC are from a third party library, so I prefer not to touch files inside it.

    I’m sorry for having deluded you, Hanra 🙂 , but with the latest version this should be already fixed

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Dropdown Options Vanish’ is closed to new replies.