mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 04:31:41 +00:00
indicar cuando un campo es obligatorio
This commit is contained in:
parent
286f561442
commit
d119c9a2fb
2 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue