Basically, if we enter special instructions line by line, it will show as plain text. We can use this solution to show it as plain text if we enter it as plain text and line text if we enter it as line by line in the text area.
- WE will store the instruction text in two variables: one for showing in plain text, i.e. in text area and another one in html which can be shown in the P tag or DIV tag.
let specialInstructions = this.ApprovalModel.get(‘custbody_nssca_additional_instructions’) || this.ApprovalModel.get(‘custbody_nssca_additional_instructions’) === ” ? this.ApprovalModel.get(‘custbody_nssca_additional_instructions’) : this.model.get(‘options’) && this.model.get(‘options’).custbody_nssca_additional_instructions ? this.model.get(‘options’).custbody_nssca_additional_instructions : undefined;
let specialInstructionsHTML = specialInstructions ? (specialInstructions.split(/\n/g) || []).join(‘ <br> ‘) : ”; - We can show and hide this based on whether the user is in edit mode or in view mode using the render function or hide and show functions.