Skip to content

Invalid DOM after generate engine extension with :text fields #2236

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

Closed
lappi-lynx opened this issue Apr 2, 2013 · 4 comments
Closed

Invalid DOM after generate engine extension with :text fields #2236

lappi-lynx opened this issue Apr 2, 2013 · 4 comments

Comments

@lappi-lynx
Copy link

Hi everyone. This bug only appears when your engine have 2 or more :text fields. With strings attributes is alright.
When I generate an engine with 2 or more text fields (that can be edited with wymeditor), I got this invalid code in my vendor/extensions/engine_name/app/views/.../admin/engine_name/_form.html.erb partial:

...
<div class='field'>
    <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
      <ul id='page_parts'>
        <% [:description, :example_text].each_with_index do |part, part_index| %>
          <li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
            <%= link_to t("#{part}", :scope => "activerecord.attributes.refinery/name:strings/name:string", :default => part.to_s.titleize), "##{part}" %>
          </li>
        <% end %>
      </ul>
      <div id='page_part_editors'>
        <% [:description, :example_text].each do |part| %>
          <div class='page_part' id='<%= part %>'>
            <%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
          </div>
        <% end %>
      </div>
    </div>

  </div>


  </div>
...

As you can see, one of closing divs is redundant and it causes some troubles in Chrome, for example I can not attach js script to this form, cause DOM is invalid. I have been searched in core code for this bug, but didn't find yet where it lives.

@parndt
Copy link
Member

parndt commented Apr 2, 2013

To aid in reproducing and debugging can you please give us the command you entered to generate the extension? Thanks!

@lappi-lynx
Copy link
Author

Yep, of course.
Actually with 1 text field everything is alright, but when you generate engine with 2 text fields - you got 1 redundant </div>, with 3 text fields - 2 redundant </div>s and so on....
rails g refinery:engine another_engine title:string description:text another_description:text
Generate 2 text fields for 1 engine

<div class='field'>
    <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
      <ul id='page_parts'>
        <% [:description, :another_description, :yet_descr].each_with_index do |part, part_index| %>
          <li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
            <%= link_to t("#{part}", :scope => "activerecord.attributes.refinery/some_engines/some_engine", :default => part.to_s.titleize), "##{part}" %>
          </li>
        <% end %>
      </ul>
      <div id='page_part_editors'>
        <% [:description, :another_description, :yet_descr].each do |part| %>
          <div class='page_part' id='<%= part %>'>
            <%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
          </div>
        <% end %>
      </div>
    </div>

  </div>


  </div>

robyurkowski added a commit that referenced this issue Apr 3, 2013
Conflicts:
	core/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_form.html.erb

Fixes #2236
parndt added a commit that referenced this issue Apr 3, 2013
@parndt
Copy link
Member

parndt commented Apr 3, 2013

Thanks, this wasn't an issue on master so I've pushed a solution already coded by @robyurkowski to 2-0-stable. Can you please try again using that?

gem 'refinerycms', :github => 'refinery/refinerycms', :branch => '2-0-stable'

@lappi-lynx
Copy link
Author

👍

parndt added a commit that referenced this issue May 30, 2013
Conflicts:
	changelog.md
parndt added a commit that referenced this issue Jun 4, 2013
Conflicts:
	changelog.md
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

2 participants