Does not f.label :documents, required: true
work?
--
You received this message because you are subscribed to the Google Groups "SimpleForm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-simp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
form.simple_fields_for :documents do |form_document|
form_document.input :number
form.label :documents, required: true
* {:number=>"Número", :issuing_institution=>"Órgão emissor", :document_type=>"Tipo do documento", :document_type_id=>"Tipo do documento"}
active_record:
models:
document: &document_attrs
number: Número
issuing_institution: Órgão emissor
document_type: Tipo do documento
document_type_id: Tipo do documento
employee: &employee_attrs
name: Nome
documents:
<<: *document_attrs
simple_form:
labels:
employee:
<<: *employee_attrs
employee: &employee_attrs
name: Nome
documents: Documentos
<<: *document_attrs
1. Is there any way to create a label with automatic required mark?
2. Any workaround or another strategy to deal with i18n for a collection name that i want to display as a field label?
<%= form.label t(:documents), required: required?(object, :documents) %>
def required?(model, model_attr)
model.validators_on(model_attr).map(&:class).include?(ActiveRecord::Validations::PresenceValidator)
end