- my $cgix = CGI::Ex->new;
- my $hashref = $cgix->get_form; # uses CGI by default
-
- ### send the Content-type header - whether or not we are mod_perl
- $cgix->print_content_type;
-
- my $val_hash = $cgix->conf_read($pathtovalidation);
-
- my $err_obj = $cgix->validate($hashref, $val_hash);
- if ($err_obj) {
- my $errors = $err_obj->as_hash;
- my $input = "Some content";
- my $content = "";
- SomeTemplateObject->process($input, $errors, $content);
- $cgix->fill({text => \$content, form => $hashref});
- print $content;
- exit;
- }
-
- print "Success\n";
-
- ### Filling functionality
-
- $cgix->fill({text => \$text, form => \%hash});
- $cgix->fill({text => \$text, fdat => \%hash});
- $cgix->fill({text => \$text, fobject => $cgiobject});
- $cgix->fill({text => \$text, form => [\%hash1, $cgiobject]});
- $cgix->fill({text => \$text); # uses $self->object as the form
- $cgix->fill({text => \$text,
- form => \%hash,
- target => 'formname',
- fill_password => 0,
- ignore_fields => ['one','two']});
- $cgix->fill(\$text); # uses $self->object as the form
- $cgix->fill(\$text, \%hash, 'formname', 0, ['one','two']);
- my $copy = $cgix->fill({scalarref => \$text, fdat => \%hash});
- my $copy = $cgix->fill({arrayref => \@lines, fdat => \%hash});
- my $copy = $cgix->fill({file => $filename, fdat => \%hash});
-
- ### Validation functionality
-
- my $err_obj = $cgix->validate($form, $val_hash);
- my $err_obj = $cgix->validate($form, $path_to_validation);
- my $err_obj = $cgix->validate($form, $yaml_string);
-
- ### get errors separated by key name
- ### useful for inline errors
- my $hash = $err_obj->as_hash;
- my %hash = $err_obj->as_hash;
-
- ### get aggregate list of errors
- ### useful for central error description
- my $array = $err_obj->as_array;
- my @array = $err_obj->as_array;
-
- ### get a string
- ### useful for central error description
- my $string = $err_obj->as_string;
- my $string = "$err_obj";
-
- $cgix->{raise_error} = 1;
- $cgix->validate($form, $val_hash);
- # SAME AS #
- my $err_obj = $cgix->validate($form, $val_hash);
- die $err_obj if $err_obj;
-
- ### Settings functionality
-
- ### read file via yaml
- my $ref = $cgix->conf_read('/full/path/to/conf.yaml');
-
- ### merge all found settings.pl files together
- @CGI::Ex::Conf::DEFAULT_PATHS = qw(/tmp /my/data/dir /home/foo);
- @CGI::Ex::Conf::DIRECTIVE = 'MERGE';
- @CGI::Ex::Conf::DEFAULT_EXT = 'pl';
- my $ref = $cgix->conf_read('settings');
+ my $hash = $cgix->form;
+
+ if ($hash->{'bounce'}) {
+
+ $cgix->set_cookie({
+ name => ...,
+ value => ...,
+ });
+
+ $cgix->location_bounce($new_url_location);
+ exit;
+ }
+
+ if (scalar keys %$form) {
+ my $val_hash = $cgix->conf_read($pathtovalidation);
+ my $err_obj = $cgix->validate($hash, $val_hash);
+ if ($err_obj) {
+ my $errors = $err_obj->as_hash;
+ my $input = "Some content";
+ my $content = "";
+ $cgix->swap_template(\$input, $errors, $content);
+ $cgix->fill({text => \$content, form => $hashref});
+ print $content;
+ exit;
+ } else {
+ print "Success";
+ }
+ } else {
+ print "Main page";
+ }