mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 11:33:38 +00:00
si la tabla de datos es un array, tenemos que poder agregar filas
This commit is contained in:
parent
8ab6b60f90
commit
7be0fc33b1
3 changed files with 15 additions and 7 deletions
|
@ -1,5 +1,4 @@
|
||||||
- root, field_name = field_name_for_post(name)
|
= hidden_field_tag field_name_for_post_as_string(name), value: 'false'
|
||||||
= hidden_field root, field_name, value: 'false'
|
|
||||||
= check_box_tag field_name_for_post_as_string(name),
|
= check_box_tag field_name_for_post_as_string(name),
|
||||||
'true',
|
'true',
|
||||||
value == 'true',
|
value == 'true',
|
||||||
|
|
|
@ -4,12 +4,22 @@
|
||||||
%tr
|
%tr
|
||||||
- template.nested_fields.each do |nf|
|
- template.nested_fields.each do |nf|
|
||||||
%td= nf.help || nf.human
|
%td= nf.help || nf.human
|
||||||
|
%td
|
||||||
|
- if template.array?
|
||||||
|
%button.btn.btn-success= t('posts.row.add')
|
||||||
%tbody
|
%tbody
|
||||||
%tr
|
%tr
|
||||||
- template.nested_fields.each do |nf|
|
- template.nested_fields.each do |nf|
|
||||||
- value = @post.new? ? nf.values : @post.get_front_matter(template)[nf]
|
- value = @post.new? ? nf.values : @post.get_front_matter(template)[nf]
|
||||||
|
-# Si el template es un array, quiere decir que esperamos un array de hashes.
|
||||||
|
-# El 0 luego es reemplazado por un id temporal
|
||||||
|
- if template.array?
|
||||||
|
- name = [template.key, '', nf.key]
|
||||||
|
- else
|
||||||
|
- name = [template.key, nf.key]
|
||||||
%td= render "posts/template_field/#{nf.type}",
|
%td= render "posts/template_field/#{nf.type}",
|
||||||
template: nf,
|
template: nf,
|
||||||
name: [template.key, nf.key],
|
name: name,
|
||||||
value: value
|
value: value
|
||||||
%td= fa_icon 'close', title: 'Eliminar'
|
- if template.array?
|
||||||
|
%td= fa_icon 'close', title: t('posts.row.del')
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
-# Si el campo está anidado, la raíz del atributo name tiene que
|
-# Si el campo está anidado, la raíz del atributo name tiene que
|
||||||
-# contener los demás elementos del template superior
|
-# contener los demás elementos del template superior
|
||||||
- root, field_name = field_name_for_post(name)
|
= text_field_tag field_name_for_post_as_string(name),
|
||||||
= text_field root, field_name,
|
value,
|
||||||
value: local_assigns[:value],
|
|
||||||
class: 'form-control',
|
class: 'form-control',
|
||||||
required: template.required?
|
required: template.required?
|
||||||
|
|
Loading…
Reference in a new issue