grupo de radios

This commit is contained in:
f 2019-01-11 15:27:19 -03:00
parent b73885af95
commit 5c68ebc74b
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
2 changed files with 21 additions and 0 deletions

View file

@ -58,6 +58,8 @@ class Post
@type = 'text_area'
when check_box_group?
@type = 'check_box_group'
when radio_group?
@type = 'radio_group'
when string?
@type = 'text'
# TODO volver a hacer funcionar esto y ahorranos los multiple:
@ -182,6 +184,10 @@ class Post
array? && (complex? && contents.fetch('checkbox', false))
end
def radio_group?
array? && (complex? && contents.fetch('radio', false))
end
def array?
value.is_a? Array
end

View file

@ -0,0 +1,15 @@
-# Obtener el nombre del campo
- field_name = field_name_for_post_as_string(name)
-# Obtener todos los valores
- value = [] if value.nil?
- values = template.values.empty? ? [value].flatten : template.values
- values.each do |v|
.form-check
= radio_button_tag field_name+'[]',
v,
@post.fetch_front_matter(name, []).include?(v),
class: 'form-check-input'
= label_tag [field_name,v].join(' '), class: 'form-check-label' do
= v.split(':', 2).first
%br/
%small= v.split(':', 2).last