For more information... RTFM!
NAVIGATION
PAGES THAT LINK HERE
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

Form callback functions

You can use the mv_click, mv_check and mv_cleanup variables to request that Interchange should make use of your pre-defined callback routines.

You can use callback routines to perform arbitrary tasks, including setting multiple variables with a single button, general form control, database updates or whatever else you might need to do in a form.

mv_click

A "mv_click" callback routine can be defined in a scratchpad variable, or in a Profiles or OrderProfile file, and can be called from a <form>.  For example:

<input type="submit" name="mv_click" value="Search by category">

[set Search by category]
    mv_search_field=category
    mv_search_file=categories
    mv_todo=search
[/set]

When the above "submit" button is clicked, the "Search by category" callback will be called, and will set variables just as if they were put in on the form.  The mv_click variable's value will not be carried from form to form;  it must be specifically set on the form being submitted.

It is very convenient to use mv_click as a trigger for embedded Perl.  For instance:

<form ...>
    <input type="hidden" name="mv_click" value="Invalid input">
    ...
</form>

[set Invalid input]
[calcn]
    my $type = $CGI->{mv_searchtype};
    my $spell_check = $CGI->{mv_spelling_errors};
    my $out = '';

    if($spell_check and $type eq 'text') {
        $CGI->{mv_todo} = 'return';
        $CGI->{mv_nextpage} = 'special/cannot_spell_check';
    }
    undef;
[/calcn]
[/set]
Note

Note

The "mv_click" callback routine will run before your order profile (if defined), and before the "mv_check" routine (if defined).  The "mv_click" callback routine will not run if a form profile fails.

mv_check

The "mv_check" form variable can be used to set variables for the "submit", "refresh", "set", "autoset" and "return" form actions.  The mv_check callback executes after the values are set from the form, including the ones set by mv_click, and can be used to condition input to search routines or orders.

The variable sets can contain, and be generated by, most of the Interchange tags.  The code is interpolated for Interchange tags before being used, and so your code may not always operate as you might expect.  For instance, if the following was set:

<form ...>
    <input type="hidden" name="mv_check" value="My check callback">
    ...
</form>

[set My check callback]
    [cgi name=mv_todo set=bar hide=1]

    mv_todo=search

    [if cgi mv_todo eq 'search']
        do something
    [/if]
[/set]

The [if] condition is guaranteed to be false because the tag interpolation takes place before the evaluation of the variable setting.

Any setting of variables already containing a value will overwrite the variable.  To build sets of variables (as in mv_search_field and mv_return_fields), comma separation must be used - if that is supported for the variable.

Note

Note

The "mv_check" callback routine will run after the mv_click callback (if defined) unless a form profile fails.  A form profile failure will prevent your "mv_check" callback routine from being called.

mv_cleanup

A "mv_cleanup" callback routine can be defined in a scratchpad variable, or in a Profiles or OrderProfile file, and can be called from a <form>.

The mv_cleanup callback routine operates like mv_click, except that it runs after all other <form> processing has been performed.

Note

Note

The "mv_cleanup" callback routine will run after the "mv_click" and "mv_check" callbacks (if defined) unless a form profile or order profile fails.  A form/order profile failure will prevent your "mv_cleanup" callback routine from being called.

Category:  Interchange forms
Last modified by: Kevin Walsh
Modification date: Saturday 26 August 2006 at 4:35 PM (EDT)
Home  |  Legal nonsense  |  Privacy policy  |  Donations  |  Contact us