Conditional logic & required fields block sending Slips once the Slip enters edit state

Staff Users are unable to send a slip with conditional logic and required fields have been configured for Parent Section fields.

Note: This only occurs when the slip has entered the edit state.

When editing a Slip created from a form template that includes conditionally required fields in the Parent section, triggered by selections in the school section, users encounter a saving error. Therefore, not able to send. This error incorrectly states that required information is missing in the Parent section, when the validation should only trigger for the parent when submitting a response to the slip. This incorrect use of validation logic occurs during the staff user attempt to send the slip to parents, rather than during the intended parent submission phase.

Expected Behaviour

  1. The system should allow staff members to edit and send slips to parents without triggering validation errors for conditionally required fields in the Parent section.

  2. These validation checks should only be enforced when the parent is submitting the Slip.

Screenshots

The Parent Slip

 

image-20240603-213735.png

The core conditional fields routines fire - irrespective of whether Slip editing, or parent submitting, that class will be present.

The slip is not meant to be blocked at this point and should send after being amended.

Technical Solution:

controller_slip_ready.js is the onReady routine which initiates the validations on Edit Slip.

We already have an ‘ignore’ piece in there:

ignore: ".no-validation", //we want to include all hidden fields (they might be on an inactive tabe, excluding fields set to hidden by conditions)

We can exclude fields from the validations by setting class = no-validation

js/pp-formFields.js is the core routines which draw fields to forms everywhere

The function makeFormFieldEdit is what fires when you Edit Slip, and draws the fields into the School Section and Parent Section

We know the routine is being used on the Edit Slip page because pageMode = user, and we know which fields are on the Parent Section because editableByContact = 1

I’ve added the following into makeFormFieldEdit:

// SSA-7 If Editing a Slip with conditional fields School>Parent sections, disable validation on parent fields if (pageMode == "user" && editableByContact == 1) { fieldVisible = " no-validation " };

So, if it is the user editing the Slip, and the field is on the Parent Section, we add the class no-validation.