5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-02 13:46:08 +00:00
panel/app/views/posts/_form.haml

55 lines
1.5 KiB
Plaintext
Raw Normal View History

- unless post.errors.empty?
2018-02-02 22:20:31 +00:00
.alert.alert-danger
2019-08-23 18:29:07 +00:00
%h4= t('.errors.title')
%p= t('.errors.help')
2018-02-02 22:20:31 +00:00
2020-06-28 00:42:32 +00:00
%ul
- post.errors.each do |attribute, errors|
- if errors.size > 1
%li
%strong= post_label_t attribute, post: post
%ul
- errors.each do |error|
%li= error
- else
%li
%strong= post_label_t attribute, post: post
= errors.first
-# TODO: habilitar form_for
:ruby
if post.new?
2020-05-26 22:02:52 +00:00
url = site_posts_path(site, locale: @locale)
method = :post
2020-06-28 00:42:15 +00:00
extra_class = 'new'
else
2020-05-26 22:02:52 +00:00
url = site_post_path(site, post.id, locale: @locale)
method = :patch
2020-06-28 00:42:15 +00:00
extra_class = 'edit'
end
2018-12-14 15:12:17 +00:00
- dir = t("locales.#{@locale}.dir")
-# Comienza el formulario
2020-06-28 00:42:15 +00:00
= form_tag url, method: method, class: 'form post ' + extra_class, multipart: true do
-# Botones de guardado
2019-08-20 22:11:10 +00:00
= render 'posts/submit', site: site, post: post
= hidden_field_tag 'post[layout]', post.layout.name
2019-11-15 16:35:27 +00:00
-# Dibuja cada atributo
2019-08-23 18:29:07 +00:00
- post.attributes.each do |attribute|
2020-11-11 20:00:09 +00:00
- metadata = post[attribute]
2019-08-23 18:29:07 +00:00
- type = metadata.type
2019-08-20 22:11:10 +00:00
- cache [metadata, I18n.locale] do
2020-11-11 20:00:09 +00:00
= render("posts/attributes/#{type}",
base: 'post', post: post, attribute: attribute,
2020-11-11 20:00:09 +00:00
metadata: metadata, site: site,
dir: dir, locale: @locale,
autofocus: (post.attributes.first == attribute))
-# Botones de guardado
2019-08-20 22:11:10 +00:00
= render 'posts/submit', site: site, post: post