5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 06:41:42 +00:00
panel/app/views/posts/template_field/_select.haml

19 lines
739 B
Text
Raw Normal View History

- if name.is_a?(Array) && name.count == 3
- value = @post.get_front_matter(name.first).try(:[], name.second.to_i).try(:[], name.last)
- else
- value = @post.get_front_matter(template.key)
- values = template.values.empty? ? value : template.values
= select_tag field_name_for_post_as_string(name),
options_for_select(values, value),
{ class: 'form-control select2',
multiple: template.multiple?,
required: template.required?,
data: { tags: template.open?,
placeholder: t('posts.select.placeholder'),
'allow-clear': template.multiple?,
'maximum-selection-length': template.max }}
- if template.open?
%small.text-muted.form-text= t('posts.open')
- if template.max > 0
%small= t('posts.select.max', max: template.max)