Skip Menu |

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 67992
Status: rejected
Priority: 0/
Queue: HTML-FormFu

People
Owner: Nobody in particular
Requestors: randomcoder1 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.09002
Fixed in: (no value)



Subject: insert_after says "position element not found"
Hi, I just attached a bug report written using Test::More. It tests finding an element in an existing form, then creating a new element, and insert_after the element which was just found. Please confirm. -- Your bugs , they are afraid of me.
Subject: bug.pl
use strict; use warnings; use HTML::FormFu; use Data::Dumper; use Test::More; my $f = HTML::FormFu->new; if($HTML::FormFu::VERSION ne "0.09002") { die "\n\nERROR: Sorry, this bug report was intended only for version 0.09002\n\n"; }; $f->load_config_file("register.yml"); #print $f; my $found_element = $f->get_all_element({name=>"captcha" }); is($found_element,"<div class=\"text label\"> <label>Please verify this captcha</label> <input name=\"captcha\" type=\"text\" /> </div>", "element found succefuly"); my $new_element = $f->element({ type=>"Block", name=>"captchaimg", tag=>"div", content_xml=>"<img src=\"\"/>", })->clone; is($new_element,"<div> <img src=\"\"/> </div>","new element constructed succesfuly"); eval { $f->insert_after($new_element,$found_element); }; is($@,"","insert_after should work properly now");
Subject: register.yml
--- action: /login indicator: submit auto_fieldset: 1 elements: - type: Text name: username label: username constraints: - Required - type: Password name: password label: password constraints: - Required - type: Password name: confirmpw label: Confirm password constraints: - Required - type: Text name: captcha label: Please verify this captcha constraints: - Required - type: Submit value: submit name: submit constraints: - SingleValue
The problem is that ->get_all_element will search recursively, but ->insert_after will only search at the top level. Since your form is using auto-fieldsets, the top level of elements of the form is just going to be a fieldset, so ->insert_after won't find the element you found earlier. One work-around is to not use auto-fieldsets; another is to call ->insert_after on the fieldset instead of the form (or, more generally, on the parent of the element after which you're trying to insert your new element).
I think this is not a bug and intend to close it as such unless the requestor wishes to make a case otherwise by the end of November 2016. Thank you.