Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semantic_form_for should output only when = is used #381

Closed
fabiokr opened this issue Sep 30, 2010 · 5 comments
Closed

semantic_form_for should output only when = is used #381

fabiokr opened this issue Sep 30, 2010 · 5 comments

Comments

@fabiokr
Copy link

fabiokr commented Sep 30, 2010

Hi there,
I'm having some trouble with formtastic and rjs forms. I have this edit.html.haml file:

= semantic_form_for @account, :remote => true do |form|
  = render :partial => 'form', :object => form

Then I have an update.js.erb:

<% if @account.errors.empty? %>
  alert('yes!');
<% else %>
  <% semantic_form_for(@account) do |form| %>
    $('edit_account_1').update("<%= escape_javascript(render(:partial => 'form', :object => form)) %>");
  <% end %>
<% end %>

My problem is, on the rjs, I don't want that semantic_form_form outputs a form element, I just need the form variable so that the partial can render the inputs. I expected that if I used semantic_form_form with only <% it would'nt output the form element. Am I doing something wrong, or is my request really valid?

@mjonuschat
Copy link
Contributor

Which formtastic and rails version are you using?

Rails 2.x still has the concatenation to the output buffer, so wether you are using <%= or not doesn't make a difference. When you are using Rails 3.x formtastic should adhere to the changes in the block level helpers and only output when used with <%=

@fabiokr
Copy link
Author

fabiokr commented Sep 30, 2010

I'm using Rails 3.0 and the latest formtastic from master =\

@justinfrench
Copy link
Member

Can you write a simple test to investigate if semantic_form_for behaves differently to Rails' own form_for? If form_for is doing the same thing, then I suspect you're "doing it wrong". There's also a fields_for which might help, not sure.

Will close in a week if I haven't heard any more.

@fabiokr
Copy link
Author

fabiokr commented Oct 2, 2010

Rails form_for haves the same behavior. I've just changed my approach, I'm replacing my entire form with rjs now. Thanks!

@justinfrench
Copy link
Member

Thanks, closing.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants