html-formhandler
a Perl Moose HTML form handler
I have an HTML::Formhandler Form on my Catalyst Framework. The Problem is, that I get an error-message in the Form, when I load the Form-Site with an HTML GET-Requelst.
has_field 'name' => (type => 'Text', required => 1);
So if I load the Site via: localhost:3000/form no errors occurs.
But if I load the Site via localhost:3000/form?foo=bar the form says: "Field required".
Any Idea how to solve this?
Source: (StackOverflow)
How to add fieldname to Formhandler errorListTemplate.singleWrap typoscript?
I have the following Typoscript :
plugin.Tx_Formhandler.settings {
singleErrorTemplate {
totalWrap = |
singleWrap = <span class="error">|</span>
}
errorListTemplate {
totalWrap = <div id="liste_erreurs"><ul>|</ul></div>
singleWrap = <li>|</li>
}
}
And I want to add the current fieldname into the errorListTemplate.singleWrap to get sommething like :
errorListTemplate {
totalWrap = <div id="liste_erreurs"><ul>|</ul></div>
singleWrap = <li for="[FIELDNAME]">|</li>
}
Thanks and have a nice day :)
Source: (StackOverflow)
My requirement is I have a hidden form from where i am calling a handle method. Along with the handle method I am setting success and error url's as hidden values.
<dsp:form action="blank.jsp" method="post" formid="UNIQUE_FORM_ID">
<dsp:input bean="FormHandler.commitOrder" type="hidden" value="submit" />
<dsp:input bean="FormHandler.commitOrderSuccessURL" type="hidden" value="SOME_VALUE" />
<dsp:input bean="FormHandler.commitOrderNotReadyURL" type="hidden" value="SOME_VALUE" />
</dsp:form>
I need to set the successurl
and errorUrl
before calling the handle method.
I tried giving priority, but still its not working.
Thanks,
Neenu
Source: (StackOverflow)
I'm using the Typo3 Formhandler extension to build a simple reaction form. The form works correctly only the error response is in English and not translated. By typoscript I included a languest file.
langFile = fileadmin/templates/sandraverdijck/lang/newsletter.xml
The languest file includes the Dutch translation, see file below.
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<data type="array">
<languageKey index="default" type="array">
<label index="error_sender_name_required">Naam is verplicht</label>
<label index="error_sender_email_required">Email is verplicht</label>
<label index="error_sender_email_email">Email is niet correct ingevult</label>
</languageKey>
</data>
</T3locallang>
The response is still in English like "Your name is missing", I don't know where it gets this from and why it is not using the text from the languest file? When I don't include the languest file I get an error so the file is used. Anyone some idee?
Source: (StackOverflow)
using HTML::Formhandler in Catalyst I defined a form based on a database table (item_class). What the form does is set the first three select lists based on the contents of several tables (other than the table on which the form is based) in the database. It looks like the select lists all get (html) correct options. However on commit I invariably get error: '...' is not a valid value ONLY for fields: prg_id and mrk_id.
What's my mistake? Any help is greatly appreciated.
My form definition:
package BskExt::Form::HMbestellingProducten;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Model::DBIC';
with 'HTML::FormHandler::Render::Table';
use namespace::autoclean;
has 'wpl_id' => ( is => 'rw' );
has '+item_class' => ( default => 'NewHmbestellingenproducten' );
has_field 'wklloc_id' => ( type => 'Select', label => 'Winkel(locatie)s' );
#has_field 'prg_id' => ( type => 'Select', label => 'Productgroep', label_column => 'naam', accessor => 'prg' );
has_field 'prg_id' => ( type => 'Select', label => 'Productgroep', error_messages => { select_invalid_value => undef } );
#has_field 'mrk_id' => ( type => 'Select', label => 'Merk', label_column => 'naam', accessor => 'mrk' );
has_field 'mrk_id' => ( type => 'Select', label => 'Merk' );
has_field 'productnaam' => ( type => 'Text', label => 'Product *', size => 32, maxlength => 40, required => 1, messages => { required => 'Verplicht' }, validate_method => \&CatFormFieldValidate::validate_name_ext );
has_field ' ' => ( type => 'Submit', id => 'submit', value => 'Ga door' );
#
# The select list for wklloc_id is set by options_wklloc_id which has been omitted from
# this listing as it made the listing (much) too long
#
sub options_mrk_id
{
my ($self) = shift;
my (@mrk_select_list);
undef(@mrk_select_list);
push @mrk_select_list, { value => '', label => 'Kies eerst een productgroep' };
return @mrk_select_list;
}
sub options_prg_id
{
my ($self) = shift;
my (@prg_select_list);
undef(@prg_select_list);
push @prg_select_list, { value => '', label => 'Kies eerst een winkel(-locatie)' };
return @prg_select_list;
}
My form template:
<script>
$(function() {
$("#wklloc_id").click(function() {
$("#prg_id").load("WinkelLocatieProductgroepen?wklloc_id=" + $("#wklloc_id").val());
});
});
$(function() {
$("#prg_id").click(function() {
$("#mrk_id").load("ProductgroepMerken?wklloc_id=" + $("#wklloc_id").val() + "&prg_id=" + $("#prg_id").val());
});
});
</script>
<p></p>
[%# Render the HTML::FormHandler Form %]
[% form.render %]
(The significant part of) my controller:
sub create : Chained('base') PathPart('create') Args(0) {
my ($self, $c ) = @_;
my $hmbestprod = $c->model('DB::NewHmbestellingenproducten')->new_result({});
return $self->form($c, $hmbestprod,'new');
}
sub form
{
my ( $self, $c, $hmbestprod, $action ) = @_;
my ($form,$klant_info,$uc_action);
$uc_action = uc($action);
$klant_info = $c->model( 'BskExt' )->KlantInfo($c->session->{"klt_id"}||0);
$form = BskExt::Form::HMbestellingProducten->new(wpl_id => $$klant_info{"wpl_id"});
# Set the template
$c->stash( template => 'hmbestellingproducten/form.tt2', action => $uc_action, form => $form );
$form->process(
use_init_obj_over_item => 1,
item => $hmbestprod,
init_object => { "aantal" => 1 },
params => $c->req->params );
return unless $form->validated;
# Set a status message for the user & return to list
$c->response->redirect($c->uri_for($self->action_for('list')));
}
#
# This helps jQuery to set the content of the ProductgroepMerken form list
#
sub ProductgroepMerken :Chained('base') :PathPart('ProductgroepMerken') :Args(0)
{
my ($self, $c) = @_;
my ($optstr,$prg_id,$productgroepmerken,$wklloc_id);
$c->log->debug("ProductgroepMerken\n");
$prg_id = $c->request->params->{"prg_id"};
$wklloc_id = $c->request->params->{"wklloc_id"};
#
# The result: $productgroepmerken contains (at first glance) valid values. These values are not in any way (directly)
# related to the FORM item_class 'NewHmbestellingenproducten'
#
$productgroepmerken = $c->model ( 'BskExt' )->ProductgroepMerken($wklloc_id,$prg_id);
undef($optstr);
foreach (@$productgroepmerken)
{
$optstr .= '<option value="'.$_->{"id"}.'">'.$_->{"naam"}.'</option>';
}
$c->log->debug("optstr= $optstr\n");
$c->response->body($optstr);
}
#
# This helps jQuery to set the content of the WinkelLocatieProductgroepen form select list
#
sub WinkelLocatieProductgroepen :Chained('base') :PathPart('WinkelLocatieProductgroepen') :Args(0)
{
my ($self, $c) = @_;
my ($optstr,$productgroepen,$wklloc_id);
$c->log->debug("WinkelLocatieProductgroepen\n");
$wklloc_id = $c->request->params->{"wklloc_id"};
#
# The result: $productgroepen contains (at first glance) valid values. These values are not in any way (directly)
# related to the FORM item_class 'NewHmbestellingenproducten'
#
$productgroepen = $c->model ( 'BskExt' )->WinkelLocatieProductgroepen($wklloc_id);
$c->log->debug("productgroepen= \n".Dumper($productgroepen)."\n\n");
undef($optstr);
foreach (@$productgroepen)
{
$optstr .= '<option value="'.$_->{"id"}.'">'.$_->{"naam"}.'</option>';
}
$c->log->debug("optstr= $optstr\n");
$c->response->body($optstr);
}
Source: (StackOverflow)
I am trying to validate a iban no for germany, but I cannot get pregMatch to work with formhandler. I cannot find a mistake and compared it with the formhandler documentation, but nothing helped. Maybe somebody has a hint for me.
This is my code:
debitiban.errorCheck {
1 = pregMatch
1.value = ^DE\d{2}\s?([0-9a-zA-Z]{4}\s?){4}[0-9a-zA-Z]{2}$
}
Source: (StackOverflow)
The documentation for HTML::FormHandler::Select says that the sort_column option Sets or returns the column or arrayref of columns used in the foreign class for sorting the options labels.
I've tried setting it, but it is not setting my options:
has_field 'my_field' => (
type => 'Select',
sort_column => 'label',
required => 1,
);
I've also tried not setting sort_column
, since the default is to sort by the label column and that's what I want, but it doesn't seem to work still. Does anyone know how to have HTML::FormHandler sort the values of my select field? Currently the values are being set with an options function:
sub options_my_field {
return [
{
value => 1,
label => 'One',
},
{
value => 2,
label => 'Two',
},
];
}
Source: (StackOverflow)
I am developing a Perl/Catalyst web app using HTML::FormHandler for forms.
I am trying to do a conditional validation on a field if a checkbox is checked.
The code below is from a Role I created for my form to use.
has_field 'autosys_jobs.schedule.has_run_day_of_month' => ( type=>'Boolean');
has_field 'autosys_jobs.schedule.run_day_of_month' => ( type => 'PosInteger');
#Validation function for 'autosys_jobs.schedule.run_day_of_month'
sub validate_autosys_jobs_schedule_run_day_of_month {
my ( $self, $field ) = @_;
if( $self->field('autosys_jobs.schedule.has_run_day_of_month')->value ) {
#validate 'autosys_jobs.schedule.run_day_of_month'
}
}
The problem I'm having is that $self->field('autosys_jobs.schedule.has_run_day_of_month')->value
for the boolean field always returns 0 even if it's checked.
Any ideas on what I'm doing wrong?
Source: (StackOverflow)
Is there any way to access the value of form field 'wklloc_id' in the form field options method of field 'prg_id'?
My Form contains (amongst others) these fields:
has_field 'wklloc_id' => ( type => 'Select', label => 'Winkel(locatie)' );
has_field 'prg_id' => ( type => 'Select', empty_select => 'Kies eerst een Winkel(locatie)', label => 'Productgroep' );
At this point my options method for field 'prg_id' contains:
sub options_prg_id
{
my ($self) = shift;
my (@prg_select_list,$productgroep,$productgroepen);
return unless ($self->schema);
$productgroepen = $self->schema->resultset( 'WinkelLocatieProductgroepen' )->search( {}, { bind => [ 2 ] } );
Is is possible to set the value of the bind variable (i.e. 2) to the value of field 'wklloc_id' and how does one do that? Mind you this is needed before any submit.
Source: (StackOverflow)
I have several HTML::FormHandler forms working nicely,
the only issue is the submit button, which does not change its text/label.
Here is (part of) my form, the labels for the other fields all work as expected.
has_field username => ( type => 'Text', label => 'Username', required => 1);
has_field name => ( type => 'Text', label => 'Name', required => 1);
has_field submit => ( type => 'Submit', label => 'Create',do_label => 1,
element_class => 'button' );
Now the element class is set and works, but the button shows 'save', not 'create'.
According to the docs, labels are not rendered for submit buttons unless
do_label is set, but for me, it makes no difference.
I have also tried giving a build_label method, also to no effect.
I'd be glad for any pointers on how I can achieve this using HTML::FormHandler methods, as I am using these forms quite extensively and would not like to put them in by hand.
Source: (StackOverflow)