[html-formfu] removing element from the form
Carl Franks
fireartist at gmail.com
Wed Jul 28 09:46:32 GMT 2010
On 28 July 2010 10:16, rahed <raherh at gmail.com> wrote:
> Benjamin Martin <benjamin at opusvl.com> writes:
>
>> I think is not working because to remove an element you need to call
>> remove_element' against the element's 'parent' ... which may not be
>> "form"
>>
>> Try this:
>>
>> [% txt = form.get_all_element('field1') %]
>> [% txt_parent = txt.parent %]
>> [% txt_parent.remove_element( txt ) %]
>
> It emits the error:
>
> Can't locate object method "" via package "HTML::FormFu::Element::Text"
I'm not sure what's causing that error message, but I'm not sure that
code's exactly what you want.
remove_element() returns the element that's removed - which in this
case will be stringified and inserted into the template.
If you don't want the field printed, then you'll need the CALL directive:
[% txt = form.get_all_element('field1') %]
[% CALL txt.parent.remove_element( txt ) %]
Carl
More information about the HTML-FormFu
mailing list