[html-formfu] Re: HTML-FormFu Digest, Vol 11, Issue 23

Joe Prosser jvprosser at gmail.com
Sat Mar 29 03:39:45 GMT 2008


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) =3D @_;


   $c->log->debug("XXXXXXXXXXXX inside customer/edit");

   $id =3D~ /\d+/ or die 'invalid id';
   my $customer =3D $c->stash->{customer} =3D
$c->model('DB::Customer')->find($id) or die "customer $id not found";

  $c->stash->{channels} =3D $c->model('DB::Channel');
  $c->stash->{services} =3D $c->model('DB::Service');

   my $form =3D $c->stash->{form};

#   $DB::single=3D1;

   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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/html-formfu/attachments/20080328/18=
528f1b/attachment.htm


More information about the HTML-FormFu mailing list