[html-formfu] How to make AJax style drop down box

kewei xiao kewei.xiao at nald.ca
Tue Jul 10 12:49:45 GMT 2007


Thank you for the hint.  now I have another problem that my customized 
province and state drop down box can't get data from database.
Also select box labels ( 'Province'  or 'State' ) are dynamically 
changed.  Can I archive that in my customized select box?  below is my code:

use strict;
use warnings;

use base qw ( HTML::FormFu::Element::select );

sub new {
  my $self = shift->SUPER::new( @_ );
 
  my $c = $self->form->stash->{ context };
  my $countries
      = $c->model( 'GuestBook::Country' )->search(
      { 'me.lang' => $c->language },
      {   order_by => 'me.country_id, subcountries.sort_name',
          prefetch => 'subcountries'
      }
  );

  while ( my $country = $countries->next ) {
        my $subcountries = $country->subcountries;
        #my $subcountry_types = 
$country->subcountries->first->subcountry_type; ( this is either label 
'Province' or label 'State', it depends on the country I chose)

        $self->options( [ {}, map { {
            label => $_->name,
            value => $_->subcountry_id }
            } $subcountries->all ] );
  };
return $self;
}


Thanks for the help

Kewei



More information about the HTML-FormFu mailing list