#66 enhancement
Ben Sommerville

Form.request does not pass options to form.serialize

Reported by Ben Sommerville | May 1st, 2008 @ 09:18 AM | in 1.7

Form.request calls Form.serialize to get the parameters to post. However it does not pass serialize the options parameter it received. This makes it impossible to specify which submit button was pressed (using options.submit).

A fixed version of Form.request is below

    request: function(form, options)
        form = $(form),options = Object.clone(options || { });

        var params = options.parameters, action = form.readAttribute('action') || '';
        if (action.blank()) action = window.location.href;
        options.hash = true;
        options.parameters = form.serialize(options);

        if (params)
            if (Object.isString(params)) params = params.toQueryParams();
            Object.extend(options.parameters, params);

        if (form.hasAttribute('method') && !options.method)
            options.method = form.method;

        return new Ajax.Request(action, options);

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins


Referenced by