I have all my forms validating. Yay!

The question I have is what happens after validation?

If I create a small form like this that doesn't use my validation stuff:

Form without validation:
<form action="" method="post">
    <table>
        <tr><td>Username:</td>
            <td>
                <select name="user_name">
                <option value=""></option>
                <option value="NAME1">NAME1</option>
                <option value="NAME2">NAME2</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
            <input type="submit" value="Login" style="width:5em;">&nbsp;
            <input type="reset" value="Reset" style="width:5em;">
            </td>
        </tr>
    </table>
    <input type="hidden" name="rm" value="show_task_page" />
</form>


When I get to the "show_task_page" I can do "$q->param('user_name')" and get the value from the form.

If I send my page through my validation I no longer can do that. I know that because I am passing the value to another page that shows up when I do it without validation and doesn't when I validate. I imagine it has to do with how I am redirecting out of the validation.

Form with validation:
<form action="" method="post">
    <table>
        <tr><td>Username:</td>
            <td>
                <select name="user_name">
                <option value=""></option>
                <option value="NAME1">NAME1</option>
                <option value="NAME2">NAME2</option>
                </select>
                <tmpl_var err_user_name>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
            <input type="submit" value="Login" style="width:5em;">&nbsp;
            <input type="reset" value="Reset" style="width:5em;">
            </td>
        </tr>
    </table>
    <input type="hidden" name="rm" value="_validate_main_form" />
</form>

Validation code:

sub _validate_task_form : Runmode {
    my $self = shift;
    my $q = $self->query;

    my ( $results, $err_page ) = $self->check_rm('show_task_page', {
required => [qw/charge_ids project_names task_name task_date total_hours/],
            constraints => {
                total_hours => qr/^(\d*(\.((00?)|(25)|(50?)|(75))0*)?)$/,
            },
            msgs => {
                any_errors => 'err__',
                prefix     => 'err_',
            },
        });

    return $err_page if $err_page;

    $self->redirect('index.cgi?rm=show_next_page');
}

How do I pass the form elements after it has been validated?

I hope I have given you enough to go by this time. I am trying to get my head around C::A and all. I suck at forms and I am trying to remedy that too!

Robert


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to