[html-formfu] Can't get element name
Ascii King
tech at swattermatter.com
Mon Aug 31 19:52:19 GMT 2009
Why doesn't this code return the name and id of the element?
I have declared all of my variables, I just didn't include it here. This
code will put the title and maxlength attributes of a text field into
the Repeatables_List, but not the id or name.
The code is supposed to find a text field that has a "title" attribute
and put a div tag right after it. The code fails because it never
actually grabs the name of the retrieved element. Why not?
I have so much trouble understanding what is going on inside of the
arrays and hashes that I work with.
-----------------------------------------
my @Repeat_List = $form->get_all_elements({ type => 'Text'});
while (@Repeat_List->[0][$count]) {
if (@Repeat_List->[0][$count]->attributes->{'title'}) {
tester = tester . "title == " .
@Repeat_List->[0][$count]->attributes->{'title'} . "<BR>";
tester = tester . "id == " .
@Repeat_List->[0][$count]->attributes->{'id'} . "<BR>";
tester = tester . "name == " .
@Repeat_List->[0][$count]->attributes->{'name'} . "<BR>";
tester = tester . "maxlength == " .
@Repeat_List->[0][$count]->attributes->{'maxlength'} . "<BR>";
$new_element = $form->element({ type => 'Block', id =>
@Repeat_List->[0][$count]->attributes->{'id'} });
# $position = @Repeat_List->[0][$count];
$position = $form->get_element({ type => 'Text', name =>
@Repeat_List->[0][$count]->attributes->{'name'} });
$form->insert_after( $new_element, $position );
}
$count++;
}
$c->stash->{Repeatables_List} = tester;
More information about the HTML-FormFu
mailing list