Closed jennyadamsnz closed 6 years ago
I have added an asterisk to the required field's labels which I believe is common practice for indicating required fields in forms. Link to saved draft: http://madewithwagtail.org/admin/pages/5/view_draft/
👍 nice! If there is an asterisk, there should be a label somewhere on the form that states "* Required field". Please try and add it if that's not too complicated.
The only thing I would be concerned with is that changing all of the field's names breaks the form's results table / CSV export. Could you check on your local instance of the site and report back?
export (9).pdf test was successful
I have also added "An asterisk [*] indicates a required field" to the start of the form http://madewithwagtail.org/admin/pages/5/view_draft/
I understand that it would work with new submissions, but what happens of old ones that were made with different field names? It's a big price to pay to lose all of that history just for some label changes.
Since the fields are marked as required in the admin, the template should be able to pick it up and add a required
class to the field like we do on all other projects. If the basic form.as_p doesn't do it, we will have to loop over the fields and do it ourselves.
Edit: Alternatively it might be possible to overwrite def get_form_fields
on core.forms.SubmitFormPage
to dynamically update the returned fields and inject {'class': 'required'}
to the widget attributes.
Edit2: Actually Wagtail already pass to the widget the required
option along so there's probably no point overwriting get_form_fields
.
Edit3: Anyway, this should be a code change, not a label change in the admin (in other words, we need to fix it not hack it).
To my surprise, adding an asterisk to the label doesn't break the CSV Export. This is because it uses clean_name when saving to the database and exporting to the CSv.
However, note that the CSV Export has been "broken" on July 31st (see #98).
Anyway, as expressed before, I strongly believe this change should be a code change, not a hack in the admin. The above PR addresses that and I'll remove the *
from the label once the PR is merged and deployed.
I've deployed the code and while the CSS change is apparent (the new class exists), the form don't get the class applied.
It's unclear which fields are required or optional. This is mentioned in a note in the "Profile description" field but this could be easily missed. I think it's good for there to be clarity here especially for regular submitters.