RA Jones ha scritto:
Marcello Romani wrote:
RA Jones ha scritto:
It looks like your output is showing both debug1 and debug2 levels, which suggests your fb config settings are not being used. Did you place

That's what I thought too.

Where do you put the "debug" option ?

I tried this:

package MyApp::Controller::FBConfig;

use strict;
use warnings;

use base qw/Catalyst::Controlloer::FormBuilder/;

sub new {
    my $class = shift;
    my $self = $class->SUPER::new(@_);
    $self->{debug} = 0;
    return 0;
}

1;

But of course it doesn't work. Could you post (some of) your code ?

Thanks you very much.

As I indicated previously, I have a sub-class of CCF containing formbuilder configuration settings (and more) which is a parent class for all my (formbuilder-using) controllers. So:

package MyApp::Controller::ClassThatUsesFormBuilder;

use lib '/path/to/my/perl-lib';
use base qw/My::Formbuilder/; # configures CCF;

sub build_form : Local Form('/users') {
  my ($self, $c) = @_;

  my $form = $self->build_user_form($c); # in My::Formbuilder

  # etc;
}

package My::Formbuilder;

use base qw/Catalyst::Controller::FormBuilder/;

__PACKAGE__->config(
  'Controller::FormBuilder' => {
    new => {
      debug => 0,
#     ^^^^^^^^^^ debug settings here
      messages => {
        # override default messages go here,
      },
      validate => {
        # complex validation routines here
      }
    }
    stash_name => 'fb', # ie fb.field.some_field.value in TT
  },
);

sub build_user_form {
  my ($self, $c) = @_;

  my $form = $self->formbuilder;

  # fields requiring complexity not available to .fb source file:
  $form->field(
    name    => 'some_field',
    options => [
      map [ $_->id, $_->location ],
        $c->model('Schema::Location')->search({},
          { order_by => 'location'} )
      ],
  );

  return $form;
}

Not only does this work, but I find it more convenient specifying formbuilder config options in one place rather than in every controller that uses CCF. Hope it works for you.

Thank you very much.

In fact I ave tried your approach but it has not worked. I'll re-check and report back (I hope this time I'll get this right!).

Thanks again.

--
Marcello Romani
Responsabile IT
Ottotecnica s.r.l.
http://www.ottotecnica.com

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to