indicar cuando un campo es obligatorio

This commit is contained in:
f 2018-06-19 13:50:39 -03:00
parent 286f561442
commit d119c9a2fb
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
2 changed files with 9 additions and 1 deletions

View file

@ -107,6 +107,13 @@ class Post
contents.fetch('open', value.count < 2)
end
def human
h = key.humanize
h = h + ' *' if required?
h
end
# Obtiene los valores posibles para el campo de la plantilla
def values
return '' if %w[string text].include? value

View file

@ -78,7 +78,7 @@
- @post.template_fields.each do |template|
- next unless type = template.type
.form-group
= label_tag "post_#{template}", template.to_s.humanize
= label_tag "post_#{template}", template.human
- name = "post[#{template}]"
- value = @post.new? ? template.values : @post.get_front_matter(template)
- case type
@ -96,6 +96,7 @@
= select_tag name, options_for_select(template.values, @post.get_front_matter(template)),
{ class: 'form-control select2',
multiple: template.multiple?,
required: template.required?,
data: { tags: template.open?,
placeholder: t('posts.select.placeholder')}}
- if template.open?