app/views/groups/_form.html.erb
<%= form_for group, html: { multipart: true } do |f| %>
<%= render "error_messages", object: group %>
<div class="form-group box p-4 mt-2rem mb-2rem">
<h3 class="mb-4">1. Group info</h3>
<div class="form-group">
<%= f.label :name %>
<small class="text-muted">Required *</small>
<%= f.text_field :name, class: "form-control",
required: true %>
</div>
<div class="form-group">
<%= f.label :location %>
<small class="text-muted">Required *</small>
<%= f.text_field :location, required: true,
placeholder: "City, country, online...",
class: "form-control" %>
</div>
<div class="form-group mb-0">
<%= f.label :description %>
<small class="text-muted">Required *</small>
<%= f.hidden_field :description, required: true %>
<trix-editor input="group_description" class="form-control">
</trix-editor>
</div>
</div>
<div class="form-group box p-4 mb-2rem">
<h3 class="mb-4">
2. Image
<small class="text-muted ml-010rem">Required *</small>
</h3>
<div class="form-group mb-0">
<%= f.label :image, hidden: true %>
<% if group.image? %>
<%= image_tag(group.image_url,
srcset: "#{group.image_url(:medium)} 510w, #{group.image_url(:thumb)} 350w",
class: "img-fluid mb-2rem") %>
<% end %>
<%= f.file_field :image %>
<%= f.hidden_field :image_cache %>
</div>
</div>
<div class="form-group box p-4 mb-2rem">
<h3 class="mb-4">3. Settings</h3>
<div class="form-group group-visible">
<h4 class="mb-4">Hide group?</h4>
<div class="row">
<div class="col-sm-1 text-center text-sm-left">
<%= f.radio_button :hidden, true,
class: "form-control" %>
</div>
<div class="col-sm-11 text-center text-sm-left mt-2 mt-sm-0">
<%= f.label :hidden, "Yes", value: true, class: "mb-1" %>
<div class="ml-1 font-italic">
<p class="mb-0">
· Group would not appear in groups listing.
</p>
<p class="mb-0">
· Only members and invitees would be able to see it.
</p>
</div>
</div>
</div>
<div class="row mt-2">
<div class="col-sm-1 text-center text-sm-left">
<%= f.radio_button :hidden, false,
checked: checked_if_not_set?(group.hidden),
class: "form-control" %>
</div>
<div class="col-sm-11 text-center text-sm-left mt-2 mt-sm-0">
<%= f.label :hidden, "No", value: false %>
</div>
</div>
</div>
<hr class="mt-4 mb-4">
<div class="form-group group-visible mb-0">
<h4 class="mb-4">Allow all members to create events?</h4>
<div class="row">
<div class="col-sm-1 text-center text-sm-left">
<%= f.radio_button :all_members_can_create_events, true,
class: "form-control" %>
</div>
<div class="col-sm-11 text-center text-sm-left mt-2 mt-sm-0">
<%= f.label :all_members_can_create_events, "Yes", value: true %>
</div>
</div>
<div class="row mt-1">
<div class="col-sm-1 text-center text-sm-left">
<%= f.radio_button :all_members_can_create_events, false,
checked: checked_if_not_set?(group.all_members_can_create_events),
class: "form-control" %>
</div>
<div class="col-sm-11 text-center text-sm-left mt-2 mt-sm-0">
<%= f.label :all_members_can_create_events, "No", value: false,
class: "mb-1" %>
<div class="ml-1 mb-2 font-italic">
<p class="mb-0">
· Only members with organizer role would be able to create events.
</p>
</div>
</div>
</div>
</div>
</div>
<% if group.persisted? && current_user == group.owner %>
<div class="form-group box p-4 mb-2rem">
<h3 class="mb-4">4. Danger zone</h3>
<div class="form-group mb-0">
<p class="font-italic mb-4">
This action is not reversible. All events in this group would also be deleted.
</p>
<%= link_to "Delete group",
group_path(group, user_id: current_user.id),
data: { confirm: "Are you sure you want to delete this group?" },
method: :delete, class: "btn btn-danger btn-lg" %>
</div>
</div>
<% end %>
<%= f.button yield(:button_text),
class: "btn btn-primary btn-block btn-lg btn-3d mt-4 mb-4",
data: { disable_with: "Saving... #{render 'spinner'}" } %>
<% end %>