Troubleshooting: Required field validation is not firing until users interact with the field

PROBLEM: A field set to "required" in field properties does not trigger validation until a user begins updating the field and reverting those changes.

RESOLUTION: If for any reason you must save a model as soon as the page loads, you will need to create an action for required fields that reverts this model to a modified state in order for validation to work.

Problem Details

For this client's use case, if a user attempted to save the record without adding any value for the required field, the save was unexpectedly successful. However, if the user attempts to type in a value, then subsequently deletes the value, the validation is now triggered when they attempt to save. The client did not want users to save the record without having a value for this field.

Resolution Process

  1. We began by determining if the field was set to be required at the field level (meaning it is required any where it is used on the page) or the component level (field required only when used inside this component). This field was set to be required only inside of the component containing it, which was a form/field editor.
  2. Then we simplified the page in increments to isolate the problem. For example, this page was used in a community and we verified this behavior was the same when used outside of the community.
  3. The field was utilized inside of a wizard component, so we verified the behavior was the same outside of the wizard component.
  4. We then checked for any rogue actions in models that may be unintentionally affecting the required field, and this is where we found the cause of the problem. There was a model action that first creates a new record, then immediately saves it without any user interaction. If we removed this action to immediately save, the validation worked as we expected.

Outcome 

This client had a particular use case that required them to create a new record and save it as soon as the page loads. Our dev team confirmed that required field validation was behaving as expected.. By design, our validation is not triggered on fields that have already been saved. Changing this behavior would have unintended affects on updating field values for records that already exist in the database.

Because the record is saved as soon as the page loads, the model no longer has unsaved changes and therefore the validation is not triggered. The resolution was to add an action to update the field to a blank value directly after the save action, which puts the model in a state where it has unsaved changes. Now if users attempt to save a record without a required value, the validation works as expected.

Takeaways

If you must save a record as soon as it is created in the Skuid action sequence, keep in mind this may affect required field validation for any components on the model. Skuid's validation does not check unmodified values for any existing records (or records that have already been saved on the page). If you must save the record on page load, you can add an action to update the field to a blank value directly after the save action to re-engage the validation.

Get help with an issue

  • Ask in the Skuid user community in the questions category.
  • If you have paid support ask your question on our support portal skuid.freshdesk.com.
  • If you’re interested in support, contact your Account Executive.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!