guardar los valores falsos closes #141

This commit is contained in:
f 2020-03-31 17:52:41 -03:00
parent 21827da354
commit e5aaed9524
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 7 additions and 7 deletions

View file

@ -15,14 +15,14 @@ class MetadataBoolean < MetadataTemplate
# En este caso, queremos priorizar el dato enviado por le usuarie
# antes que el generado internamente.
def value
return false if false?
return false if self[:value] == '0'
return self[:value] unless self[:value].nil?
self[:value].present? || document.data.fetch(name.to_s, default_value)
document.data.fetch(name.to_s, default_value)
end
private
def false?
self[:value] == '0'
def save
self[:value] = !%w[0 false].include?(self[:value])
true
end
end

View file

@ -1,6 +1,6 @@
.form-check
= hidden_field_tag "post[#{attribute}]", '0'
= check_box_tag "post[#{attribute}]", metadata.value, metadata.value,
= check_box_tag "post[#{attribute}]", '1', metadata.value,
class: "form-check-input #{invalid(post, attribute)}",
aria: { describedby: id_for_help(attribute) },
autofocus: autofocus