Skip Menu |

This queue is for tickets about the Maypole-FormBuilder CPAN distribution.

Report information
The Basics
Id: 14864
Status: new
Priority: 0/
Queue: Maypole-FormBuilder

People
Owner: Nobody in particular
Requestors: rmcclain [...] megapath.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: generic form postprocessor
Sometimes all the trickery used by process_fields, form_builder_defaults, etc.. gets in the way. All I want to do is tweak some values for the form right before rendering. How about a hook that you would override in your model classes like so: sub form_post_process { my($self, $form) = @_; } where $form is the CGI::FormBuilder object. Maybe you'd want to pass in the CDBI::FB instance too, but not sure why you'd need it offhand.
Date: Sat, 1 Oct 2005 00:49:16 +0100
From: David Baird <dave.riverside [...] gmail.com>
To: bug-Maypole-FormBuilder [...] rt.cpan.org
Subject: Re: [cpan #14864] generic form postprocessor
RT-Send-Cc:
On 9/30/05, Guest via RT <bug-Maypole-FormBuilder@rt.cpan.org> wrote: Show quoted text
> > Sometimes all the trickery used by process_fields, form_builder_defaults, etc.. gets in the way. All I want to do is tweak some values for the form right before rendering. > > How about a hook that you would override in your model classes like so: > > sub form_post_process { > my($self, $form) = @_; > } > > where $form is the CGI::FormBuilder object. Maybe you'd want to pass in the CDBI::FB instance too, but not sure why you'd need it offhand. >
Why can't you post-process the form after you get it back from CDBI::FB? d.
From: rmcclain [...] megapath.net
[dave.riverside@gmail.com - Fri Sep 30 19:49:37 2005]: Show quoted text
> On 9/30/05, Guest via RT <bug-Maypole-FormBuilder@rt.cpan.org> wrote:
> > > > Sometimes all the trickery used by process_fields,
> form_builder_defaults, etc.. gets in the way. All I want to do is > tweak some values for the form right before rendering.
> > > > How about a hook that you would override in your model classes like
> so:
> > > > sub form_post_process { > > my($self, $form) = @_; > > } > > > > where $form is the CGI::FormBuilder object. Maybe you'd want to
> pass in the CDBI::FB instance too, but not sure why you'd need it > offhand.
> >
> > Why can't you post-process the form after you get it back from > CDBI::FB? > > d.
You mean in the template? I could, but don't like it. There are certain things that just shouldn't be modified in the template. Plus, in TT, you'd have to use ugly [% PERL %] blocks to modify it, because far as I know, CGI::FB doesn't use TT calling conventions. Finally, this wouldn't work for what I want to do. Many, but not all of my tables have a series of standard columns (created_by, created_ts, updated_by, updated_ts) with obvious meanings. These should not be in the form. I don't always remember to make the adjustments to my model classes (overriding edit_columns and addnew_columns). I'd like to just have a method in my base class that gets rid of these fielrelated_class_and_rel_typeds if they are there. I've also run into a few instances where the field processors act strangely (to me anyway.. i've mentioned a couple of these in other threads), and I'd just like to be able to manually tweak the form. I could do it in the template, but it'd be ugly, and it forces the template writer (in this case me, but you know..) to be aware of stuff that is purely on the backend.
Date: Sat, 1 Oct 2005 21:25:27 +0100
From: David Baird <dave.riverside [...] gmail.com>
To: bug-Maypole-FormBuilder [...] rt.cpan.org
Subject: Re: [cpan #14864] generic form postprocessor
RT-Send-Cc:
On 10/1/05, Guest via RT <bug-Maypole-FormBuilder@rt.cpan.org> wrote: Show quoted text
> > This message about Maypole-FormBuilder was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=14864 > > > [dave.riverside@gmail.com - Fri Sep 30 19:49:37 2005]: >
> > On 9/30/05, Guest via RT <bug-Maypole-FormBuilder@rt.cpan.org> wrote:
> > > > > > Sometimes all the trickery used by process_fields,
> > form_builder_defaults, etc.. gets in the way. All I want to do is > > tweak some values for the form right before rendering.
> > > > > > How about a hook that you would override in your model classes like
> > so:
> > > > > > sub form_post_process { > > > my($self, $form) = @_; > > > } > > > > > > where $form is the CGI::FormBuilder object. Maybe you'd want to
> > pass in the CDBI::FB instance too, but not sure why you'd need it > > offhand.
> > >
> > > > Why can't you post-process the form after you get it back from > > CDBI::FB? > > > > d.
> > You mean in the template? I could, but don't like it. There are > certain things that just shouldn't be modified in the template. Plus, > in TT, you'd have to use ugly [% PERL %] blocks to modify it, because > far as I know, CGI::FB doesn't use TT calling conventions. Finally, > this wouldn't work for what I want to do. Many, but not all of my > tables have a series of standard columns (created_by, created_ts, > updated_by, updated_ts) with obvious meanings. These should not be in > the form. I don't always remember to make the adjustments to my model > classes (overriding edit_columns and addnew_columns). I'd like to just > have a method in my base class that gets rid of these > fielrelated_class_and_rel_typeds if they are there. I've also run into > a few instances where the field processors act strangely (to me anyway.. > i've mentioned a couple of these in other threads), and I'd just like > to be able to manually tweak the form. > I could do it in the template, but it'd be ugly, and it forces the > template writer (in this case me, but you know..) to be aware of stuff > that is purely on the backend. >
Fair enough, I'll add the hook. For the time being, you could look at the post_process argument. It's not exactly what you want, because it takes some extra optional arguments which need to be taken into account in your coderef. Its main purpose is to override render(), but you can also use it to apply your post-processing and then call the render coderef. d.