Page MenuHomePhabricator

PageForms: Hidden mandatory fields without defaults can keep the user from submitting the form without any error message
Open, Needs TriagePublic

Description

Example form:

<noinclude>This is a simple form.
{{#formlink:form=Simple|link text=Test|link type=button|new window}} 
</noinclude><includeonly>
{{{info|page name=<unique number>}}}
{{{field|confirm|input type=text|input type=radiobutton|values=No,Yes|default=No|show on select=Yes=>Confirm|mandatory}}}
<div id=Confirm>
{{{field|review|input type=radiobutton|values=maybe,maybe not|mandatory|restricted=YouAreNOTinThisGroup}}}
</div>
</includeonly>

When the user does not select "Yes" but tries to submit the form, the form re-appears without an indication of what is wrong.

When the user selects "Yes" and tries to save, they see the error There were errors with your form input; see below. and, below, "None" is selected and greyed out ( T231957: PageForms: Should allow user to submit a form if there are restricted mandantory fields without defaults that the user cannot fill) and, beneath that, cannot be blank is displayed in red text.

Event Timeline

Yes, that's not ideal... what do you think the behavior should be, if there are mandatory-but-not-visible fields that are left blank?

I think this problem can be resolved by not doing error checking on
hidden fields. If they are hidden, the user hasn't had a chance to see
them.

If there is a default value, I think it should be saved when the form is
submitted (though I can see an argument against that), but, otherwise,
the hidden fields should not affect the user's experience.

That seems like the right approach, yes. I think someone else made that request too recently, but I can't remember where. Hopefully this is easy to do.

I think it should be saved when the form is submitted (though I can see an argument against that)

I agree that this is tricky. I'm thinking about what would happen if:

  1. The page is saved with Option #1 selected and there is a hidden mandatory field under Option #2. The form saves a default value for the hidden field.
  2. Then, the hidden field's default value is changed.
  3. Then, an editor edits the page and switches to Option #2.

At this point the editor will see an old and invalid default value. What I think should happen instead is that the default value be left blank in step 1 so that when step 3 happens, the correct default value will be inserted.

I guess this is my "argument against that". :)