Skip to content
Snippets Groups Projects
Commit 075c115d authored by Arnaud Levy's avatar Arnaud Levy
Browse files

better forms

parent 765ac176
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,21 @@ module Admin::ApplicationHelper
collection
end
def collection_tree_for_checkboxes(list, except = nil)
collection = collection_tree(list, except)
collection.map { |object|
[
sanitize(object[:label]),
object[:id],
{
data: {
parent: object[:parent_id]
}
}
]
}
end
private
def polymorphic_url_param(object_or_class, **options)
......
......@@ -11,6 +11,17 @@
<%= f.input :text, as: :rich_text_area %>
</div>
</div>
<div class="card flex-fill w-100">
<div class="card-header">
<h5 class="card-title mb-0"><%= t('activerecord.attributes.communication/website/post.categories') %></h5>
</div>
<div class="card-body">
<%= f.association :categories,
label_text: false,
as: :check_boxes,
collection: collection_tree_for_checkboxes(@website.categories) if @website.categories.any? %>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card flex-fill w-100">
......@@ -28,13 +39,6 @@
<%= f.input :published_at, html5: true %>
<%= f.input :pinned %>
<%= f.association :author, collection: current_university.people.authors.ordered %>
<%= f.association :categories,
as: :check_boxes,
collection: collection_tree(@website.categories).map { |category| [
sanitize(category[:label]),
category[:id],
{ data: { parent: category[:parent_id] } }
] } if @website.categories.any? %>
</div>
</div>
<div class="card flex-fill w-100">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment