Hi, Happy New Year etc...
I'm hoping that someone is able to offer some advice for the best way to optimize a form. I currently have a rather complex form where there are a dynamic number of rows of input options (repeatable block) and in each row ~ 25 input elements. The trouble is that via a Catalyst app it seems to take n seconds to process the form ($form->process()), where n is the number of rows. Outside of catalyst the processing takes a consistent 1 second (admittedly without any form data). Has anyone got any tips on how to investigate the cause of the lag in-situ of a Catalyst application? Or perhaps be able to offer any insights to where my inefficiencies may lie (please see below for more details). I notice using NYTProf that nested_names and nested_name are heavily called. What would be the best way to reduce these calls? Thanks in advance Stephen my form is as follows: form_error_message_xml: Your sheet contained errors please review and re submit<br/> auto_constraint_class: constraint_%t elements: - type: Block elements: - type: Block tag: table attributes: class: triss_input campl-vertical-stacking-table elements: - type: Hidden name: rows value: 10 - type: Repeatable name: entries nested_name: entry elements: - type: Block tag: tr elements: - type: Weeklyusage name: usage id: weekusage auto_block_id: 'rt_%r' - type: Block tag: tr elements: - type: Block tag: td attributes: colspan: 10 elements: - type: Textarea label: Notes name: tsh_notes attributes: style: "width:100%; height:5em" - type: Submit value: Add row name: submit_add_row attributes: class: left_float - type: Submit value: Save for later name: submit_save attributes: class: left_float My rather complex row elements is defined as: package HTML::FormFu::Element:: Weeklyusage; use Moose; use MooseX::Attribute::Chained; extends 'HTML::FormFu::Element::Block'; use Moose::Util qw( apply_all_roles ); #This element will create four table row for: #Half hour, hour, half day, day selects sub process { my ( $self, @args ) = @_; $self->_add_elements(); #should this also do the adding after the filtering etc? # return $self->SUPER::process(@args); } sub _add_elements { my ($self) = @_; $self->_elements( [] ); $self->_add_week_hours(); } sub _add_week_blanks { my ($self) = @_; my $tr = $self->element('Block'); $tr->tag('tr'); $tr->attributes({'style'=>''},{'class'=>'week_blank'}); foreach ((1..7)){ my $td = $tr->element('Block'); $td->tag('td'); } } sub _add_week_hours { my ($self) = @_; my $td = $self->element('Block'); $td->tag('td'); my $options_equipment=[]; $td->element( { type => 'Select', name => "_equipment_", #id => "_equipment_", options => $options_equipment, constraints => [{type=>'TRISS::AllOrNoneRepeatable',others=>["_account_","_equipment_"],message=>"*"}], attributes => { class=>"_equipment_ width10", empty_first=>1},# } ); my $td1 = $self->element('Block'); $td1->tag('td'); my $options_account=[]; $td1->element( { type => 'Select', name => "_account_", options => $options_account, attributes => { class=>"_account_ width10"},## } ); my $options=[{value=>"",label=>""}]; map { push @{$options}, {'value'=>$_,'label'=>$_.".0 hrs"} } (1..24); my $options_half=[{value=>"",label=>""}]; map { push @{$options_half}, {'value'=>$_*0.5,'label'=>$_*0.5." hrs"} } (1..48); my $options_mins=[{value=>"",label=>""}]; map { push @{$options_mins}, {'value'=>$_*10,'label'=>$_*10.0." mins"} } (1..48); my $options_fullday=[{value=>"",label=>""},{'value'=>'1','label'=>'1 day'}]; my $options_halfday=[{value=>"",label=>""},{'value'=>'1','label'=>'0.5 day'},{value=>'2','label'=>'1 day'}]; foreach ((1..7)){ my $td = $self->element('Block'); $td->tag('td'); $td->element( { type => 'Select', name => "_hours_".$_, options => $options, constraints => ['Number'], attributes => {class=>"_hours_ hide width8"}, } ); my $element1 = $td->element( { type => 'Select', name => "_halfhours_".$_, options => $options_half, constraints => ['Number'], attributes => {class=>"_halfhours_ hide width8"}, } ); my $element2 = $td->element( { type => 'Select', name => "_fullday_".$_, options => $options_fullday, constraints => ['Number'], attributes => {class=>"_fullday_ hide width8"}, } ); my $element3 = $td->element( { type => 'Select', name => "_halfday_".$_, options => $options_halfday, constraints => ['Number'], attributes => {class=>"_halfday_ hide width8"}, } ); my $element4 = $td->element( { type => 'Select', name => "_mins_".$_, options => $options_mins, constraints => ['Number'], attributes => {class=>"_mins_ hide width8"}, } ); } $self->element('Block')->tag('td')->element( { type => 'Text', name => "_total_", attributes => {size=>10, readonly=>'readonly',class=>"width14"}, plugins => [{type=>'TRISS::TotalTime', fieldlist=>['1','2','3','4','5','6','7'], classof=>'_equipment_'} ], } ); return; } sub render_data { #TODO: #unhide any of the selects for equipment that has been selected #append the types to our option equipment option values return shift->render_data_non_recursive(@_); } sub render_data_non_recursive { my ( $self, $args ) = @_; my $render = $self->SUPER::render_data_non_recursive( { elements => [ map { $_->render_data } @{ $self->_elements } ], $args ? %$args : (), } ); return $render; }
_______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu