# Flexi Form Removal and Revamp - Consumer Application Pages Branch: `flexi-form-removal-and-revamp` --- ## Overview The consumer application add, lead-add and edit pages used a "flexi form". On each page load, `public/js/en.js` fetched a JSON config from the `page_config` table, built form fields in the browser and inserted them into the page. The edit page also filled their values from `POST /api/get-application-data`. This revamp removes that dependency. All fields the flexi form rendered are now plain Blade markup in `edit_v1.blade.php`, prefilled on the server. The config editor in the admin header is removed, and the flexi-only routes are commented out. Saving needed no PHP change, because `store()` and `getEditPostConsumerApplication()` already saved these fields from the normal form submit. The edit page's read-only rule, field locking and new pincode/mobile checks are now in the blade's JS. ### Pages affected All three pages render the same blade, `resources/views/admin/consumer-application/edit_v1.blade.php`. | Page | Controller method (GET) | `$page_type` | |---|---|---| | `admin/consumer-applications/add` | `ConsumerApplicationController@create` | `'create'` | | `admin/consumer-applications/lead-add` | `ConsumerApplicationController@createConsumerLead` | `'lead'` | | `admin/consumer-applications/edit/{application_id}` | `ConsumerApplicationController@edit` | not set | The list page `admin/consumer-applications` also had a `page_config` row, but with `fields: []`, so the flexi form never rendered anything there. --- ## Fields moved to Blade (27) Each field is placed where the flexi form inserted it: right after the same anchor element. Element ids, wrapper ids, names, classes, placeholders, `minlength`/`maxlength`, `onkeyup` filters and `data-required` were copied from the edit page config. Values are `Request::old('', ?? '')`. Dropdown option lists are PHP arrays in `@php` blocks, so each list exists once. A dropdown only pre-selects an option that exactly matches the stored value; if the stored value isn't in the list, the select shows empty (same as before). Every one of these inputs/selects has the class `post-approval-unlocked` (see "Field locking" below). ### Applicant Details | Field | `name` | Saved to | Placed after | Notes | |---|---|---|---|---| | Preferred Language | `preferred_language` | `consumer_application_element.preferred_language` | `#lender_id_attr` | Inside the hidden `#languageSelection` block toggled by the "Update - Preferred language" link. Required. ENGLISH pre-selected on add and lead-add when nothing is stored; empty on edit when nothing is stored. | | Father Name | `father_name` | `consumer_application_element.father_name` | `#customer_name_attr` | Required. Letters and spaces only (`onkeyup`). | | Mother Name | `mother_name` | `consumer_application_element.mother_name` | `#father_name_attr_div` | Not required. The red `*` that the flexi form showed is removed. | | Alternate Mobile | `alt_contact_number` | `consumer_application.alt_contact_number` | `#phone_number_view` | Digits only, max 10. | | Email | `email` | `consumer_application.email` | `#alternate_mobile_attr_div` | Required. After Alternate Mobile on all pages (lead-add used to place it after Mother Name). | | Education Level | `education_level` | `consumer_application_element.education_level` | `#monthly_income` | 10th Grade, 12th Grade, Graduation, Post graduation, Masters | | Caste | `applicant_caste` | `consumer_application_element.applicant_caste` | `#education_level_attr` | Schedule Tribe, General, Minority, Schedule Caste, Other Backward Class, Others | | Religion | `applicant_religion` | `consumer_application_element.applicant_religion` | `#caste_attr` | Required on all pages. HINDU, MUSLIM, CHRISTIAN, SIKHS, SIKH, JAINS, JAIN, ZOROASTRIANS, BUDDHIST, PARSI, BHAHAI, Others (the edit/add list; lead-add's shorter list is gone). | | Loan Type | `loan_type` | `consumer_application_element.loan_type` | `#religion_box_attr` | Fresh, BT | | Unique ID Number | `unique_id_number` | `consumer_application_element.unique_id_number` | `#merchant_name` | Inside the hidden `#uniqueIDForm` block toggled by the "Unique ID Number" link. | | Video KYC | `video_kyc` | `consumer_application_element.video_kyc` | `#video_kyc_selection_attr` | | ### Merchant Representative Details | Field | `name` | Saved to | Placed after | Notes | |---|---|---|---|---| | Name | `merchant_representative_name` | `consumer_application_element.merchant_representative_name` | `#representative_name_selection_attr` | | | Mobile | `merchant_representative_mobile` | `consumer_application_element.merchant_representative_mobile` | `#representative_mobile_selection_attr` | Digits only, max 10. | | Email | `merchant_representative_email` | `consumer_application_element.merchant_representative_email` | `#representative_email_selection_attr` | | ### Employment Details | Field | `name` | Saved to | Placed after | Notes | |---|---|---|---|---| | Profession | `employee_status` | `consumer_application.employee_status` | `#profession_attr` | UNEMPLOYED, SALARIED, BUSINESS, Self Employed - Business, Self Employed - Professional, PENSIONER, HOUSEWIFE | ### Applicant Address and Solar Installation Address Details City, Landmark and Pincode go after the address lines row (`#applicant__address_div`). Status goes after the State row (`#applicant__address_state`). Element ids are unchanged (for example `#permanent_address_city`), because the existing address JS (the "same as" checkboxes, autofill, address-change comparison) selects them by id. | Field | `name` | Saved to | |---|---|---| | Permanent Address City / Landmark / Pincode / Status | `permanent_address_city`, `permanent_address_landmark`, `permanent_address_pincode`, `permanent_address_status` | `consumer_application` | | Current Address City / Landmark / Pincode / Status | `current_address_city`, `current_address_landmark`, `current_address_pincode`, `current_address_status` | `consumer_application` | | Installation Address City / Landmark / Pincode / Status | `installation_address_city`, `installation_address_landmark`, `installation_address_pincode`, `installation_address_status` | `consumer_application_element` | Status options (shared by all three): RENTED, OWNED, PARENTS HOUSE, Self Owned, Parent Owned, Rented With Family, Rented With Friend, Company Allotted. Pincodes accept digits only, max 6. --- ## Flexi fields discarded (not moved to Blade) | Field(s) | Was on | Reason | |---|---|---| | `lender` (select), `pan_no` (input), `gender` (radio) | all three | `show: false` in every config, so the flexi form never rendered them. | | `loan_applied_for`, `loan_applied_for_mobile`, `loan_applied_for_relation` | all three | Never saved: not in `ConsumerApplicationElement::$fillable` and not assigned anywhere in PHP. Their row only rendered inside `@if(application_element->loan_applied_for)`, which could never be true. The static "Additional Details" block holding them was deleted too. | | `panel` (flexi copy, Panel to be Installed) | edit (when purpose = 6), lead-add | Duplicate of the static `panel` select in the Solar & Panel tab. PHP keeps the last value for a repeated name, so the static select (rendered later on the page) was always the one saved. The static select and its option list (`ConsumerApplicationController::panelList()`) are unchanged. See "Known differences" for the options this drops. | | `approved_amount`, `designation`, `department`, `contact`, `company_number`, `profession` (Company Type), `experience` (flexi copies) | lead-add | Duplicates of static fields already in the blade. Only the static copies remain. On master the flexi copy was the one saved for `company_number`, `profession` and `experience`, because it came later on the page; now the static copy is saved. | --- ## Other changes ### Flexi rendering removed - `footer.blade.php`: removed the `$(document).ready` block that called `get_json_page_config()`, `parseJSONToForm()` and `_mm_txr()`. Masking still works for the new static fields because `masking.js` runs `_mm_txr()` on load. ### Edit page read-only rule (ported from the config's `after_execution`) - New `