Ok. I got a newer version from the googlecode site and installed it, but I
still can't get dynamic selects working!
Here's the yml:
cat ./root/forms/customer/add.yml
---
indicator: submit
auto_fieldset: { legend : 'Person information' }
elements:
- type: Text
name: odoon_customer_id
label: Odcustid
constraints:
- Required
- type: Text
name: day_to_send_invoice
label: Day to Send Invoice
constraints:
- Required
- type: Text
name: month_to_send_invoice
label: Month to Send Invoice
constraints:
- Required
- type: Select
label: Channel
name: personality_fkey
model_config:
DBIC:
resultset: channels
- type: Radiogroup
label: Personality
name: personality_fkey
auto_id: "%n_%c"
options:
- [ '1', 'AbleVoice' ]
- [ '2', 'Odoon' ]
- [ '3', 'DaoCon' ]
constraints:
- Required
- type: Repeatable
nested_name: cust_details
increment_field_names: 1
db:
delete_if_true: delete
new_empty_row: Customer_detail
elements:
- type: Hidden
name: pkey
- type: Text
name: additional_description
- type: Select
name: service_fkey
model_config:
DBIC:
resultset: services
- type: Text
name: number_of_units
- type: Text
name: unit_calculation_script
- type: Checkbox
name: delete
- type: Submit
name: submit
value: OK
constraints:
And here's the controller code:
sub edit : Local FormConfig('customer/add.yml') {
my ($self, $c, $id) = @_;
$c->log->debug("XXXXXXXXXXXX inside customer/edit");
$id =~ /\d+/ or die 'invalid id';
my $customer = $c->stash->{customer} =
$c->model('DB::Customer')->find($id) or die "customer $id not found";
$c->stash->{channels} = $c->model('DB::Channel');
$c->stash->{services} = $c->model('DB::Service');
my $form = $c->stash->{form};
# $DB::single=1;
if ($form->submitted_and_valid) {
$form->save_to_model($customer);
$c->response->redirect($c->uri_for('/')); $c->detach;
} elsif (! $form->submitted ) {
$form->defaults_from_model($customer);
}
}
What's happening is that the first Select is displaying what appears to be
$c->stash->{customer} and the second select doesn't have any content. WHat's
more, the name of the resultset in the yml doesn't seem to matter.
Regards,
-Joe
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu