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

form_tag does not allow more then one on a page #23

Closed
klclee opened this issue Nov 21, 2012 · 4 comments
Closed

form_tag does not allow more then one on a page #23

klclee opened this issue Nov 21, 2012 · 4 comments

Comments

@klclee
Copy link

klclee commented Nov 21, 2012

I am using slim templates for my rails application. But something strang is happening. In my application template I have a form like so:

= form_tag search_path, class:'navbar-search pull-left', remote: true
= text_field_tag :term, nil, class: 'search-query span2', placeholder: 'Search'

That renders well on my page and the search form is working fine. However in my sign up partial I have:

= form_tag '/auth/identity/callback'
        - if @identity && @identity.errors.any?
        div.error
            h2 =pluralize(@identity.errors.count, 'error')
            |prohibited this account from being saved:
            ul
                - @identity.errors.full_messages.each do |msg|
                    li =msg
    h1
        i.iconbig-lock
        | Sign In
    div.login-fields
        p Sign In using your email:
        div.field
            = label_tag :auth_key, 'Email'
            = text_field_tag :auth_key, nil, class: 'input login username-field', placeholder: 'Email'
        div.field
            = label_tag :password, 'Password'
            = password_field_tag :password, nil, class:'login password-field', placeholder: 'password'
        div.login-actions
            = submit_tag 'Login', class: 'btn-signin btn btn-primary'
        div.login-social.marg10-btm
            p Sign in using social network:
            a.btn
                = image_tag 'twitter-18.png'
                |  Signin with twitter
            a.btn href="/auth/facebook"
                = image_tag 'facebook-18.png'
                |  Signin with Facebook

the form tag doesn't render, but all sub elements text fields (including the 'authenticity_token') renders fine.

I play around abit and notice that the page only allow 1 form_tag. Ones created after the first never renders. I been looking on google for a while and could not figure why. Any ideas?

@leogalmeida
Copy link
Contributor

Try adding 'do' in the end of both form tags:

= form_tag search_path, class:'navbar-search pull-left', remote: true do

= form_tag '/auth/identity/callback' do

Let me know if it solves the problem.

@klclee
Copy link
Author

klclee commented Nov 21, 2012

awsome thx!

@minad
Copy link
Member

minad commented Nov 21, 2012

@leogalmeida : What is the reason for this? Is this a Slim or a Rails problem? Do you have to add the do in erb too?

@leogalmeida
Copy link
Contributor

Answered here: slim/issues/319

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