[html-formfu] Problem with DBIC and multiple item with belongs_to
related element
Carl Franks
fireartist at gmail.com
Mon Dec 22 10:03:25 GMT 2008
2008/12/19 Nigel Metheringham <nigel.metheringham at dev.intechnology.co.uk>:
> I've been struggling with an issue where I have a DBIC row object, which =
has
> several related rows, each with a belongs_to relation within them, which I
> wanted to render in a form as a SELECT element. However I have never been
> able to make that work within my application (typically I cannot make it
> fill the SELECT options when there is more than one item in the form).
>
> So I have tried to make a test case that replicates this.
> The test case fails in a different way - it doesn't even get the related
> rows (although the select appears to fill with options).
Are you sure that's the interface you're wanting?
If it starts off with 2 related rows, there will be 2 select menus, so
the user wouldn't have the option to choose more or less rows, and
they may accidentally choose duplicates.
I'd suggest a multi-valued field would be more appropriate - either a
Radiogroup, or a single Select with multiple(1) set.
The config below works for this.
The model_config->{resultset} populates the field with all the Band
rows. - make sure you call $form->process() before calling
$form->model->default_values($row).
And the model_config->{default_column} makes the correct options be
checked/selected by using the band id.
---
auto_fieldset: 1
elements:
- type: Hidden
name: id
- type: Text
name: name
- type: Radiogroup
name: user_bands
model_config:
resultset: Band
default_column: band
- type: Submit
name: submit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: has_many_multi_value.yml
Type: application/octet-stream
Size: 249 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20081222/a=
f8f0f8a/has_many_multi_value.obj
More information about the HTML-FormFu
mailing list