Default Profile.template.php does not use js_onsubmit

Started by faeryty, July 25, 2014, 04:20:31 AM

Previous topic - Next topic

faeryty

I've been working on a mod which for UI reasons I want to make use of the js_onsubmit property of a new field I'm adding to the $profile_fields array in loadProfileFields() Profile-Modify. However, this property doesn't seem to get used, instead being substituted for the js property.

I think the problem itself is a wrong variable on line 1356. Here's the section in question :

// Some javascript!
    echo '
        <script type="text/javascript"><!-- // --><![CDATA[
            function checkProfileSubmit()
            {';

    // If this part requires a password, make sure to give a warning.
    if ($context['require_password'])
        echo '
                // Did you forget to type your password?
                if (document.forms.creator.oldpasswrd.value == "")
                {
                    alert("', $txt['required_security_reasons'], '");
                    return false;
                }';

    // Any onsubmit javascript?
    if (!empty($context['profile_onsubmit_javascript']))
        echo '
                ', $context['profile_javascript'];

    echo '
            }';

    // Any totally custom stuff?
    if (!empty($context['profile_javascript']))
        echo '
            ', $context['profile_javascript'];

    echo '
        // ]]></script>';

it seems that the first $context['profile_javascript'] should be $context['profile_onsubmit_javascript'] or am I missing something?

Arantor

Nope, you're not missing something. It actually is a bug and should indeed be profile_onsubmit_javascript.

As a dirty workaround, you could use the later $context['profile_javascript'] to replace the call to checkProfileSubmit() with your own and simply have your function call checkProfileSubmit() before returning.

faeryty

Thanks, I was reasonably sure I was right but didn't want to go breaking things with my mod.

My own dirty workaround was just to use the mod to replace the dodgy line in the template with what it should be.

Thanks again for the confirmation.

Arantor

That works too - it's just that I'm *so* used to trying to avoid file edits that I find ever more interesting ways around things, so a kludge involving replacing one function call with another is dirty but somehow cleaner, heh.

Of course, if it then gets fixed in a future patch, the mod needs to be changed.

butchs

I have been truly inspired by the SUGGESTIONS as I sit on my throne and contemplate the wisdom imposed upon me.

Arantor

Well, if this were 6 months ago it might have done. 2.0.6 and 2.0.7 (and in one case 2.0.8) contained non security bug fixes - but only because I'd put them there. If you're already going to the trouble of doing a patch update, you might as well fix any low hanging fruit you already got there.

But this is merely one of the many frustrations I encountered.

Advertisement: