# Form Question

**URL:** <https://www.ruby-forum.com/t/form-question/184600>\
**Category:** Rails\
**Created:** [March 5, 2010, 2:48am UTC](https://www.ruby-forum.com/t/form-question/184600 "2010-03-05T02:48:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [March 5, 2010, 2:48am UTC](https://www.ruby-forum.com/t/form-question/184600/1 "2010-03-05T02:48:25Z")

</div>

I have a custom form builder that output form elements as

- So

- tag which  
causes the formatting to be weired. How can I generate this link and  
position it within the 
- tag it is supposed to remove? I think the  
answer might be very simple, i am just not clear about how to move an  
elements while creating it.

---

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [March 5, 2010, 9:52am UTC](https://www.ruby-forum.com/t/form-question/184600/2 "2010-03-05T09:52:09Z")

</div>

> elements while creating it.  
> I would recommend you do it either as:

\<%= form.input :last\_name, :links =\> [{:name =\> “clear”, :function =\>  
“this.up(‘li’).remove()”}] %\>

or:

\<% form.input :last\_name do %\>  
\<%= link\_to\_function “clear”, :id =\> , “this.up(‘li’).remove()” %\>  
\<% end %\>

Either way you’re going to have to amend your custom form builder. Your  
form builder is already outputting the

- . If you’re doing it the  
second  
way (which I’d recommend as it’s more flexible) remember you can’t have  
\<%=  
with do/end so you have to use concat to output the content if  
block\_given?  
(within your input method).

Alternatively, you could do it with jQuery or something similar - give  
the  
link a class and then have a DOM ready event move any items with that  
class  
within the previous sibling.

Cheers,

Andy
