[html-formfu] Issues with Repeatable blocks
Nigel Metheringham
nigel.metheringham at dev.intechnology.co.uk
Tue Oct 14 13:27:57 BST 2008
I'm experimenting with Repeatable blocks, in conjunction with
::Model::DBIC, to produce multiple subsections within a form
representing the related objects to the main object I am dealing with.
There are 2 related issues I have with doing this:-
1. Group elements - I am using Select, but this should
behave the same with the similar elements.
If I manually set the value/options list this works fine - all
subsections have the appropriate bits in the Select element:-
elements:
- legend: Booking
type: Fieldset
elements:
- label: Booking Type
name: booking_type
type: Select
values:
- Performance
- Dress
However if I use a resultset to populate this - which works on
a single (ie not Repeatable) form, the data is pulled from the
database, but the Select item appears as if no options were
given to it:-
- legend: Booking
type: Fieldset
elements:
- label: Booking Type
name: booking_type
type: Select
model_config:
resultset: BookingType
2. I have some date elements which depend on the parent object.
Ideally I'd be able to describe the form so that the options were
populated from a method of that object (or similar callback).
However, since that is not available to me I have been attempting
to populate them within the Catalyst controller:-
# get the form
my $form = $c->stash->{form};
# graft the dates in
foreach ( @{ $form->get_all_elements() } ) {
next
unless ( defined($_)
&& defined( $_->name )
&& ( $_->name =~ /^date/ ) );
$_->options($date_option_set);
}
In a similar way to the resultset problem above, this also does
not
populate the Select appropriately, unless I move the foreach loop
down to the bottom of the code and put it in this block after
default populate:-
unless ( $form->submitted ) {
$form->model->default_values($object);
}
So basically I now appear to be fighting the system as to when various
expansions take place. Any ideas?
Nigel.
--
[ Nigel Metheringham Nigel.Metheringham at InTechnology.com ]
[ - Comments in this message are my own and not ITO opinion/policy - ]
More information about the HTML-FormFu
mailing list