[html-formfu] HTML::FormFu::Elements::Repeatable and DBIx::Class

Carl Franks fireartist at gmail.com
Thu Nov 26 15:38:29 GMT 2009


2009/11/26 Ascii King <tech at swattermatter.com>:
>
> As near as I can tell, FormFu wants the id field in a  repeatable element to
> be a Hidden element. So, you create a new id field in your intermediary
> table that can be the hidden id field and you set your repeatable
> nested_name to the has_many relationship, not the many-to-many. You use the
> many-to-many relationship when you want to display it.

If I'm following correctly, you should be able to get rid of the
Repeatable, and the Select would work with your many-to-many if it
were named 'skills', but the user will only be able to use it
correctly if you set multiple(1) so they can select more than one item
- or you could use a Radiogroup field instead.

> [% FOREACH hero IN object -%]
> </tr>
>  <td>[% hero.hero_name %]</a></td>
>  <td>
>    [% FOREACH unique_skill = hero.hero_skill %]
>        [[% unique_skill.rank %]] [% unique_skill.skill_id.skill_name %]<br
> />
>    [% END %]
>  </td>
> </tr>
> [% END -%]
> </table>
>
> Please notice the odd relationship to get the rank to display. [%
> unique_skill.skill_id.skill_name %]
> If there is some data-integrity reason why I can't do it this way, please
> tell me. I hope this helps someone.

How would you expect to otherwise refer to the 'skill_name'?
[% unique_skill.skill_id %] refers to the My::HeroSkill->skill_id
relationship, and returns a My::Skill
[% unique_skill.skill_id.skill_name %] returns the
My::Skill->skill_name column value.

Carl



More information about the HTML-FormFu mailing list