Skip Menu |

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

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

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

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



Subject: form_builder_defaults not working
I'm not able to set form_builder_defaults using the class method.. i.e. __PACKAGE__->form_builder_defaults({stuff}) or My::Model->form_builder_defaults({stuff}) or My::Model->form_builder_defaults->{key} = val I have to use: sub form_builder_defaults { stuff } I did some poking around, and it looks like my settings are getting killed at the end of M:P:FB->setup(), where it iterates through the model classes nuking the fb_defaults settings. When the model first gets use'd is when the values get set, just to get blown away there. I'm using M:FB:M:Plain if that makes a difference, though looking at the code, I don't see how it could work in any case. Is it working for you? The reason I need this is because I want to set some options in my base class, and then add to them in the model classes. I can get around it pretty easily by adding all the common options to each model, but it's ugly.
Date: Mon, 26 Sep 2005 01:29:53 +0100
From: David Baird <dave.riverside [...] gmail.com>
To: bug-Maypole-FormBuilder [...] rt.cpan.org
Subject: Re: [cpan #14730] form_builder_defaults not working
RT-Send-Cc:
On 9/24/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=14730 > > > I'm not able to set form_builder_defaults using the class method.. i.e. > __PACKAGE__->form_builder_defaults({stuff}) or > My::Model->form_builder_defaults({stuff}) or > My::Model->form_builder_defaults->{key} = val > > I have to use: > sub form_builder_defaults { stuff } > I did some poking around, and it looks like my settings are getting killed at the end of M:P:FB->setup(), where it iterates through the model classes nuking the fb_defaults settings. When the model first gets use'd is when the values get set, just to get blown away there. I'm using M:FB:M:Plain if that makes a difference, though looking at the code, I don't see how it could work in any case. Is it working for you? > > The reason I need this is because I want to set some options in my base class, and then add to them in the model classes. I can get around it pretty easily by adding all the common options to each model, but it's ugly. >
Yes, I've documented this in the upcoming release. You can't set up form_builder_defaults in the model classes themselves, because as you saw, these settings get nuked at the end of setup(). So you have to make the form_builder_defaults calls after setup(), probably in the driver itself. I did this to explicitly block the inheritable nature of these settings. There are some settings that could be global, but there are plenty that you don't want forms to inherit from each other. How about a form_builder_globals config? d.
Date: Mon, 26 Sep 2005 11:05:59 +0100
From: David Baird <dave.riverside [...] gmail.com>
To: bug-Maypole-FormBuilder [...] rt.cpan.org
Subject: Re: [cpan #14730] form_builder_defaults not working
RT-Send-Cc:
On 9/26/05, David Baird <dave.riverside@gmail.com> wrote: Show quoted text
> On 9/24/05, Guest via RT <bug-Maypole-FormBuilder@rt.cpan.org> wrote:
> > > > 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=14730 > > > > > I'm not able to set form_builder_defaults using the class method.. i.e. > > __PACKAGE__->form_builder_defaults({stuff}) or > > My::Model->form_builder_defaults({stuff}) or > > My::Model->form_builder_defaults->{key} = val > > > > I have to use: > > sub form_builder_defaults { stuff } > > I did some poking around, and it looks like my settings are getting killed at the end of M:P:FB->setup(), where it iterates through the model classes nuking the fb_defaults settings. When the model first gets use'd is when the values get set, just to get blown away there. I'm using M:FB:M:Plain if that makes a difference, though looking at the code, I don't see how it could work in any case. Is it working for you? > > > > The reason I need this is because I want to set some options in my base class, and then add to them in the model classes. I can get around it pretty easily by adding all the common options to each model, but it's ugly. > >
> > Yes, I've documented this in the upcoming release. You can't set up > form_builder_defaults in the model classes themselves, because as you > saw, these settings get nuked at the end of setup(). So you have to > make the form_builder_defaults calls after setup(), probably in the > driver itself. > > I did this to explicitly block the inheritable nature of these > settings. There are some settings that could be global, but there are > plenty that you don't want forms to inherit from each other. > > How about a form_builder_globals config? >
Sorry, scratch that last bit. There are 2 distinct sets of form_builder_defaults - one in each subclass (set up by CDBI-FB), and one in the Maypole model (set up by Maypole::FormBuilder::Model). The latter is where you can put global settings that should be applied to all forms. CGI-FB takes a lot of options, and CDBI-FB and Mp-FB add to them, so overriding different arguments may or may not work as you need it to. I'm taking it case by case, so if something doesn't work, let me know. In the general case, a key in a more specific set of arguments completely obliterates a key in a less specific set. So arguments passed to as_form, override those in the subclass's form_builder_defaults, which override those in the base model's defaults. A few keys work a bit harder at only overriding subkeys, if you see what I mean. d.