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

36 lines
868 B
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
-# TODO: habilitar form_for
:ruby
if post.new?
url = site_posts_path(site)
method = :post
else
2019-08-16 23:12:22 +00:00
url = site_post_path(site, post.id)
method = :patch
end
2018-12-14 15:12:17 +00:00
-# Comienza el formulario
= form_tag url, method: method, class: 'form post', multipart: true do
-# Botones de guardado
2019-08-20 22:11:10 +00:00
= render 'posts/submit', site: site, post: post
-# Dibuja cada atributo
2019-08-23 18:29:07 +00:00
- post.attributes.each do |attribute|
-# El borrador se muestra distinto
- next if attribute == :draft
2019-08-20 22:11:10 +00:00
2019-08-23 18:29:07 +00:00
- metadata = post.send(attribute)
- type = metadata.type
2019-08-20 22:11:10 +00:00
2019-08-23 18:29:07 +00:00
= render("posts/attributes/#{type}",
post: post, attribute: attribute,
metadata: metadata, site: site)
-# Botones de guardado
2019-08-20 22:11:10 +00:00
= render 'posts/submit', site: site, post: post