# Ajax based form - render action breaks form

**URL:** <https://www.ruby-forum.com/t/ajax-based-form-render-action-breaks-form/171432>\
**Category:** Rails\
**Created:** [July 2, 2009, 1:36pm UTC](https://www.ruby-forum.com/t/ajax-based-form-render-action-breaks-form/171432 "2009-07-02T13:36:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhaval\_parikh33](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@dhaval\_parikh33](https://www.ruby-forum.com/u/dhaval_parikh33)\
**Post date:** [July 2, 2009, 1:36pm UTC](https://www.ruby-forum.com/t/ajax-based-form-render-action-breaks-form/171432/1 "2009-07-02T13:36:09Z")

</div>

hi all,

i’ve 4 select boxes in a form(\_form.rhtml), one dependent on the  
other. initially, when form is loaded, only 1st box is enabled. after  
selecting value in 1st select box, it inserts 2nd, on 2nd’s change, 3rd  
gets inserted and on 3rd’s change, 4th gets inserted. this flow works  
perfect for me. i’ve used ajax for this flow. this form then is sent to  
back end java application thru xml request which then sends xml response  
as success or failure.

on success, i redirect control to action=\>new again and on failure,  
render the same page. while rendering on failure, my 2nd,3rd,4th select  
boxes disappears from the form where as other form field stay with their  
current inserted values.

what should i do to keep those fields in the form with their current  
values? i hope i’ve explained the scenario properly. let me know if not.

-DP

---

<div class="post-metadata">

**Author:** ![dhaval\_parikh33](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@dhaval\_parikh33](https://www.ruby-forum.com/u/dhaval_parikh33)\
**Post date:** [July 3, 2009, 1:05pm UTC](https://www.ruby-forum.com/t/ajax-based-form-render-action-breaks-form/171432/2 "2009-07-03T13:05:39Z")

</div>

Any help?

-DP

---

<div class="post-metadata">

**Author:** ![dhaval\_parikh33](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@dhaval\_parikh33](https://www.ruby-forum.com/u/dhaval_parikh33)\
**Post date:** [July 3, 2009, 2:46pm UTC](https://www.ruby-forum.com/t/ajax-based-form-render-action-breaks-form/171432/3 "2009-07-03T14:46:31Z")

</div>

2009/7/2 Dhaval P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Â on success, i redirect control to action=\>new again and on failure,  
> render the same page. while rendering on failure, my 2nd,3rd,4th select  
> boxes disappears from the form where as other form field stay with their  
> current inserted values.
> 
> Â what should i do to keep those fields in the form with their current  
> values? i hope i’ve explained the scenario properly. let me know if not.

When re-displaying you must pass the selections to the form and  
display all select boxes if the values are present. Or something  
along those lines.

Colin
