Edit Page

Main Functionalities:
Edit Selected product if it's exist
Edit Request go through some validation.
Filter inputs from any malicious script.
Check if all required fields come with request or not.
Check if the SKU exists in the database. If it does not, verify whether it is unique or not.
Check if price and product type properties are numeric.
List Error of each input below it
Before rendering the page, I exploded the Product Type Properties Fields and used type casting to send the properties to the frontend, allowing them to be rendered in their respective fields. Then, using JavaScript, I checked the type coming with the request so I could append the inputs for the specific property.
Request Scenario:
after you click on save button ajax request are sent with value of every field.
In Backend, i validate all fields with validations i said before and reply with a response with errors if exists
If ajax catch that the response contain errors i start to list all errors under its specific field.
if there isn't any error, product will be edited to database using its type Model and based on its id then i reply with success response and display a success message to user.
Last updated