mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 04:41:43 +00:00
grupo de radios
This commit is contained in:
parent
b73885af95
commit
5c68ebc74b
2 changed files with 21 additions and 0 deletions
|
@ -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
|
||||
|
|
15
app/views/posts/template_field/_radio_group.haml
Normal file
15
app/views/posts/template_field/_radio_group.haml
Normal 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
|
Loading…
Reference in a new issue