<% content_for :javascript_includes do %> <%= javascript_include_tag "/assets/ckeditor/ckeditor" %> <% end %> <%= simple_form_for [:admin, @hotel], wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_collection, file: :horizontal_file } do |f| %> <%= f.error_notification %> <%= f.input :name %> <%= f.input :phone %> <%= f.input :rating, collection: Hotel::RATING %> <%= f.input :address, as: :text %> <% index = 0%> <%= f.simple_fields_for :hotel_images do |p| %> <% if p.object.new_record? %> <%= p.input :image, as: :file, input_html: { multiple: true, name: "hotel[hotel_images_attributes][][image]" } %> <% else%> <% if index == 0%>
<%= link_to "Add New Image", new_admin_hotel_image_path(@hotel.id), class: "btn btn-success", remote: true %>
<% end %> <% index +=1 %> <%= image_tag p.object.image.url(:thumb), class: "img-fluid" %> <%= link_to "edit", edit_admin_hotel_image_path(@hotel.id, p.object.id), class: "btn btn-primary", remote: true %> <%= link_to "delete", admin_hotel_image_path(@hotel.id, p.object.id), class: "btn btn-danger", :method => :delete, data: {:confirm => "Are you sure?"} %> <% if index == f.object.hotel_images.size.to_i %>
<% end %> <% end %> <% end %> <%= f.input :description, as: :ckeditor, input_html: { ckeditor: { toolbar: 'Basic' } } %>
<%= f.button :submit, class: "btn-primary" %> <%= link_to "Cancel", admin_hotels_path(:page => params[:page]), class: "btn btn-outline-secondary" %>
<% end %>