[html-formfu] Re $form->get_field with dynamic insert elements

kewei xiao kewei.xiao at nald.ca
Thu Nov 1 20:07:54 GMT 2007


Hi Carl

     I don't get email from the list, so every time I have to write a 
new email for replying.  Sorry about that

    here are all the code snippet:

YAML part:
  - type: Block
    tag: fieldset
    id: copyright
    elements:
      - type: Block
        tag: legend
        content: Copyright      
      - type: +NSSAL::Activities::Form::Element::CopyRightStatus
        container_tag: ~
        id: status_list
        name: status_list
        attributes_xml: { onchange: "addInfo(this.id)" }
        attributes:
          class: radiogroup
----------------------------------------------------------------------------------------------------------------------
Custome Element part:

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

sub new {
    my $self = shift->SUPER::new( @_ );

    my $c = $self->form->stash->{ context };

    my $status
        = $c->model( 'Activities::CopyrightStatus' )->search;

    $self->options( [ map { {
        label => $_->description,
        value => $_->status_id },
    } $status->all ] );

    return $self;

}
----------------------------------------------------------------------------------------------------------------------------------
Fill the default value part:
    if ( $c->req->param('resources') ) {
        $form->get_field( 'resources' )->default( 
$activity->copyright_resources );
    }

When I click a radio button, the textarea will pop up.

when I go to update page, if the radio button is checked by default, i 
want that textare to be pop up and with content in it.

hope this can explain what I am looking for ,  Thanks Carl



More information about the HTML-FormFu mailing list