Ajax form error handling


#1

Hi,

I have a customer add form in which i call form_remote_tag to update a
customer list within another div on my page.

I need to also, however, allow for proper error checking, and the issue
is that the form_remote_tag will only update a single div tag.

I have seen a few ways to deal with this, but I want to know what the
best way is, while still allowing the model to do all of the
verification.

Thanks,
Ryan L.


#2

Ryan L. wrote:

Hi,

I have a customer add form in which i call form_remote_tag to update a
customer list within another div on my page.

I need to also, however, allow for proper error checking, and the issue
is that the form_remote_tag will only update a single div tag.

I have seen a few ways to deal with this, but I want to know what the
best way is, while still allowing the model to do all of the
verification.

Thanks,
Ryan L.

I have NO idea how to do it… :frowning:

Someone help us ( I work with Ryan )


#3

with rjs you can solve this

if @object.save
normal_routine
else
page.replace_html ‘error_div’, content_tag( ‘div’, error_message_on(
‘model’, ‘field’ ), ‘class’ => ‘error_text’ )
end

hope that helps