问题
In the simple_form initializer there is this line
# How the label text should be generated altogether with the required text.
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
I removed the comment and changed it to
# How the label text should be generated altogether with the required text.
config.label_text = lambda { |label, required, explicit_label| "#{label}" }
But this doesnt affect the asterisk in the required fields. The * is still present in the labels. How can i remove the asterisk in the required field?
UPDATE:
I am uploading the image. The askterisk is present even after server restart.
回答1:
ok so i forgot when generating simple form i used bootstrap flag. That created a second initializer file called simple_form_bootstrap.rb. So the change had to be made in this file. After the change in this file, it is working.
回答2:
I believe a hacky fix is to just do it through css:
abbr[title="required"] {
display: none;
}
replace abbrwith whatever selector selects the *
来源:https://stackoverflow.com/questions/52799060/how-to-remove-asterisk-in-required-fields-when-using-simple-form