hello list,

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

I have a form with a has_many, which in the first step i populate dynamically like this:

sub buildCompaniesForm : Private {
  my ( $self, $c ) = @_;
my $companies = $c->model('Matrix::Companies')->search({zeugnis => 'y' },{order_by => 'long_name asc'});
  my @elements; my $count = 0;
push @elements, { type => 'Fieldset', legend => 'Your Values', id => 'zeugnis_fs'};
  while (my $company = $companies->next) {
      $count++;
      push @elements , {
          type => 'Multi',
          label   => $company->long_name." *",
          elements => [ {
              type => 'Radiogroup',
name => 'note_'.$count, options => [[ '1', '1' ], [ '2', '2' ], [ '3', '3' ], [ '4', '4' ], [ '5', '5' ] ],constraints => [ 'Integer', 'Required', ],

          }],
      },
      {
type => 'Hidden', name => 'company_'.$count, value => $company->id

      },;
  }
  $c->stash->{form}->populate( {
      elements => [EMAIL PROTECTED]
  } );
}

after creation I would like to have an edit-option, which works well via Repeatable and nested_name, with the following config:

element:
- type: Fieldset
  legend: "Your Values"
  id: zeugnis_fs

- type: Repeatable
  nested_name: zeugnisnoten
  counter_name: count

  elements:
    - type: Hidden
      name: id

    - type: Multi
--->    label: company.long_name <---
      elements:
         type: Radiogroup
         name: note
         options:
           - [ '1', '1' ]
           - [ '2', '2' ]
           - [ '3', '3' ]
           - [ '4', '4' ]
           - [ '5', '5' ]
         constraints:
           Required

---> indicates my wish. how could I get (or is it impossible?) some value/string from my model? or what would be a useful workaround without breaking up all the automatism and traversing the form in my controller and replace the labels by selecting the hidden id and getting the label that way...

my schema like that:

__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.Zeugnis');
__PACKAGE__->add_columns(qw/id user company note/);
__PACKAGE__->set_primary_key('id');
__PACKAGE__->might_have(company => 'Xatalyst::Schema::Matrix::MatrixCompanies',{'foreign.id' => 'self.company'},{cascade_delete => 0});

thanks
josef



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

Reply via email to