[html-formfu] How to make AJax style drop down box
Carl Franks
fireartist at gmail.com
Thu Aug 2 15:59:04 GMT 2007
On 10/07/07, kewei xiao <kewei.xiao at nald.ca> wrote:
> 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;
> }
Sorry this got passed over.
Are you still having a problem with this?
If so - could you explain exactly what the problem is - I didn't
really get it the first time.
Cheers,
Carl
More information about the HTML-FormFu
mailing list