= effective_form_with(model: page, url: page.persisted? ? effective_pages.admin_page_path(page.id) : effective_pages.admin_pages_path) do |f|
= f.text_field :title
= f.check_box :draft,
label: 'Save this page as a draft. It will not appear in a menu and can only be accessed by admin users.'
= f.text_field :meta_description,
hint: "150 character summary. Appears on Google search results underneath the page title. ",
input_html: { maxlength: 150 }
- if (layouts = EffectivePages.layouts).length > 1
= f.select :layout, layouts
- else
= f.hidden_field :layout, value: layouts.first
- if (templates = EffectivePages.templates).length > 1
= f.select :template, templates
- else
= f.hidden_field :template, value: templates.first
- if f.object.persisted? || f.object.errors.include?(:slug)
- current_url = (effective_pages.page_url(f.object) rescue nil)
= f.text_field :slug, hint: "The slug controls this page's internet address. Be careful, changing the slug will break links that other websites may have to the old address.
#{('This page is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '' + f.object.slug + '').html_safe, current_url)) if current_url }".html_safe
= render partial: '/admin/pages/additional_fields', locals: { page: page, form: f, f: f }
- if f.object.persisted? && f.object.menu_root_with_children?
.alert.alert-info.my-3.pl-0
%ul.mb-0
%li This page is a top level menu item with at least one child page
%li It will render on the menu as a dropdown link
%li Users will not be able to click access page via the menu
%li Visiting the page URL directly will return a 404 error
%li If you want this page to be accessible while also being a top level menu item, it needs to have no child pages
- if f.object.persisted? && !f.object.menu_root_with_children?
= render '/admin/pages/rich_text_areas', page: page, f: f
-# This is for duplicate
- if f.object.new_record? && f.object.rich_texts.present?
= render '/admin/pages/rich_text_areas', page: page, f: f
= effective_submit(f)