si la tabla de datos es un array, tenemos que poder agregar filas

This commit is contained in:
f 2018-06-20 12:25:52 -03:00
parent 8ab6b60f90
commit 7be0fc33b1
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
3 changed files with 15 additions and 7 deletions

View file

@ -1,5 +1,4 @@
- root, field_name = field_name_for_post(name)
= hidden_field root, field_name, value: 'false'
= hidden_field_tag field_name_for_post_as_string(name), value: 'false'
= check_box_tag field_name_for_post_as_string(name),
'true',
value == 'true',

View file

@ -4,12 +4,22 @@
%tr
- template.nested_fields.each do |nf|
%td= nf.help || nf.human
%td
- if template.array?
%button.btn.btn-success= t('posts.row.add')
%tbody
%tr
- template.nested_fields.each do |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}",
template: nf,
name: [template.key, nf.key],
name: name,
value: value
%td= fa_icon 'close', title: 'Eliminar'
- if template.array?
%td= fa_icon 'close', title: t('posts.row.del')

View file

@ -1,7 +1,6 @@
-# Si el campo está anidado, la raíz del atributo name tiene que
-# contener los demás elementos del template superior
- root, field_name = field_name_for_post(name)
= text_field root, field_name,
value: local_assigns[:value],
= text_field_tag field_name_for_post_as_string(name),
value,
class: 'form-control',
required: template.required?