mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 16:53:38 +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)
|
contents.fetch('open', value.count < 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def human
|
||||||
|
h = key.humanize
|
||||||
|
h = h + ' *' if required?
|
||||||
|
|
||||||
|
h
|
||||||
|
end
|
||||||
|
|
||||||
# Obtiene los valores posibles para el campo de la plantilla
|
# Obtiene los valores posibles para el campo de la plantilla
|
||||||
def values
|
def values
|
||||||
return '' if %w[string text].include? value
|
return '' if %w[string text].include? value
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
- @post.template_fields.each do |template|
|
- @post.template_fields.each do |template|
|
||||||
- next unless type = template.type
|
- next unless type = template.type
|
||||||
.form-group
|
.form-group
|
||||||
= label_tag "post_#{template}", template.to_s.humanize
|
= label_tag "post_#{template}", template.human
|
||||||
- name = "post[#{template}]"
|
- name = "post[#{template}]"
|
||||||
- value = @post.new? ? template.values : @post.get_front_matter(template)
|
- value = @post.new? ? template.values : @post.get_front_matter(template)
|
||||||
- case type
|
- case type
|
||||||
|
@ -96,6 +96,7 @@
|
||||||
= select_tag name, options_for_select(template.values, @post.get_front_matter(template)),
|
= select_tag name, options_for_select(template.values, @post.get_front_matter(template)),
|
||||||
{ class: 'form-control select2',
|
{ class: 'form-control select2',
|
||||||
multiple: template.multiple?,
|
multiple: template.multiple?,
|
||||||
|
required: template.required?,
|
||||||
data: { tags: template.open?,
|
data: { tags: template.open?,
|
||||||
placeholder: t('posts.select.placeholder')}}
|
placeholder: t('posts.select.placeholder')}}
|
||||||
- if template.open?
|
- if template.open?
|
||||||
|
|
Loading…
Reference in a new issue