Am 07.07.2008 um 16:48 schrieb Carl Franks:

2008/7/6 Josef Chladek <[EMAIL PROTECTED]>:
hello list,

is there a way to have formfu make dynamic labels, aka labels from a
dbic-row?

okay, I've added support for this in the subversion repository.

You can now add a 'label' model_config to any field or multi block, like so:
type: Multi
model_config:
  label: 'label-col'

At the moment, if there's a relationship of the same name, it'll call
$row->get_column($label) - otherwise it does $row->$label.

This means it supports non-column accessors, but it also means that
the column must be on the particular row that's being processed.
(ie, you can't do 'table.col' to reference another table)
Can anyone think of a sensible way to handle that?

Thanks for the good idea.

carl, that's great! but I have a few problems getting the (label)data back to the form.
as I wrote before I have the following schemas:

__PACKAGE__->table('Matrix.Zeugnis');
__PACKAGE__->add_columns(qw/id user company companyname note/);
__PACKAGE__->utf8_columns(qw/companyname/);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->might_have(company => 'Xatalyst::Schema::Matrix::MatrixCompanies');

__PACKAGE__->table('Matrix.ZeugnisUser');
__PACKAGE__->add_columns(qw/id vorname nachname description email pic country/);
__PACKAGE__->utf8_columns(qw/vorname nachname description/);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->has_many(zeugnisnoten => 'Xatalyst::Schema::Matrix::Zeugnis', 'user');

__PACKAGE__->table('Matrix.Companies');
__PACKAGE__->add_columns(qw/id short_name long_name ... /);
__PACKAGE__->utf8_columns(qw/long_name/);
__PACKAGE__->set_primary_key('id');

I am able to get the companyname by using

- type: Repeatable
 nested_name: zeugnisnoten
 counter_name: count

 elements:
   - type: Hidden
     name: id

   - type: Multi
     model_config:
         label: companyname

but I have to eval line 243
 eval{$block->label( $dbic->$label );};

otherwise I get an error (I have 4 has_many rows, but it happens that it enters row 243 after getting the four rows successfully with "companyname" as label, which throws)

Caught exception in Cat::Controller::Zeugnis->get "Can't locate object method "company" via package "Cat::Model::Matrix::ZeugnisUser" at / Users/josef/perl5.10.0/lib/site_perl/5.10.0/HTML/FormFu/Model/DBIC.pm line 243."

because companyname is defined in Zeugnis but not ZeugnisUser

I can't find the reason, why the label would be generated n+1 times, so is the eval ok (nothing's missing in the form)...

and it would be fine to write company.long_name so I could use the might_have accessor, but I don't know how to change the code without disturbing the "normal" way...

thanks
josef


_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to