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

[BUG] Selected List throwing ActionView::Template::Error with ActionView 7.2 #502

Open
tobischo opened this issue Aug 12, 2024 · 0 comments
Labels

Comments

@tobischo
Copy link

Describe the bug

After upgrading Rails/ActionView to v7.2 an exception started to be raised, during test execution as well as in the UI:

     Failure/Error: raise ArgumentError, "Invalid HTML5 tag name: #{name.inspect}" unless /\A[a-zA-Z][^\s\/>]*\z/.match?(name)

     ActionView::Template::Error:
       Invalid HTML5 tag name: "<label for=\"scope_field_name\" class=\"label\">Entity</label>"

To Reproduce
Steps to reproduce the behavior:

  1. Create a project with Rails 7.2
  2. Add ActiveAdmin + ActiveAdmin Addons
  3. Setup a field with selected_list
  4. Open page showing the form element
  5. See Error
        f.inputs do
          f.input :field_name,
                  as:           :selected_list,
                  display_name: :display_name,
                  fields:       [:display_name],
                  predicate:    'cont',
                  url:          '/admin/entity',
                  label:        'Entity'
        end

Expected behavior
It renders the select field as it did before on Rails 7.1.3.4

Screenshots

  • none -

Additional context

class SelectedListInput < ActiveAdminAddons::InputBase
  def render_control_wrapper
    template.content_tag(:div, class: "selected-list-container") do
      template.content_tag(:label) #patch to ensure no html is passed
      template.concat(render_items_list)
      template.concat(builder.select(build_virtual_attr, [], {}, input_html_options))
    end
  end
end
  • The same would apply for the other input types
@tobischo tobischo added the bug label Aug 12, 2024
karlentwistle pushed a commit to BiggerPockets/activeadmin_addons that referenced this issue Aug 19, 2024
martingregoire added a commit to honeypotio/activeadmin_addons that referenced this issue Sep 20, 2024
Rails 7.2 added some logic to validate HTML5 when rendering. As it turns
out, activeadmin_addons has an invalid call to `content_tag`.

This is the error shown when rendering a page that uses a "selected list"
input field:

```
 ActionView::Template::Error:
   Invalid HTML5 tag name: "<label for=\"company_talent_ids\" class=\"label\">Presented talents</label>"

 # .../gems/actionview-7.2.1/lib/action_view/helpers/tag_helper.rb:589:in `ensure_valid_html5_tag_name'
 # .../gems/actionview-7.2.1/lib/action_view/helpers/tag_helper.rb:530:in `content_tag'
 # .../bundler/gems/activeadmin_addons-32295448e739/app/inputs/selected_list_input.rb:29:in `block in render_control_wrapper'
 # .../gems/actionview-7.2.1/lib/action_view/helpers/capture_helper.rb:50:in `block in capture'
 # .../gems/actionview-7.2.1/lib/action_view/buffers.rb:75:in `capture'
 # .../gems/actionview-7.2.1/lib/action_view/helpers/capture_helper.rb:50:in `capture'
 # .../gems/actionview-7.2.1/lib/action_view/helpers/tag_helper.rb:534:in `content_tag'
 # .../bundler/gems/activeadmin_addons-32295448e739/app/inputs/selected_list_input.rb:28:in `render_control_wrapper'
 # .../bundler/gems/activeadmin_addons-32295448e739/app/inputs/selected_list_input.rb:4:in `render_custom_input'
 # .../bundler/gems/activeadmin_addons-32295448e739/lib/activeadmin_addons/support/input_base.rb:14:in `to_html'
 # .../bundler/gems/activeadmin_addons-32295448e739/lib/activeadmin_addons/support/enumerize_formtastic_support.rb:13:in `input'
 # .../gems/arbre-1.7.0/lib/arbre/rails/forms.rb:31:in `proxy_call_to_form'
 # .../gems/activeadmin-3.2.5/lib/active_admin/views/components/active_admin_form.rb:72:in `input'
```

see platanus#502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant