Published on 09/16/2019
Published by Swapnil k
AW Form Service
AW Form service usage note:
fields_config:
In this module all forms fileds are declared.
To add new form add the config subarray inside the form_topics array
Form config array contains:
- atts
- update_service
- This service is use to handle the form data after submit
- More details explained bellow
- callback_service
- This service is optional, it used for do the specific activities after the form submission
- Also you can pass the form specific parameters using atts eg. admin mail etc.
- update_service
- groups
- In this field mention the all form groups with label as the group label
- In the group declare all the form fields this fields will come from the form_control2 service
Sample:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
[env.set_array form_topics] [sample-form] [atts update_service='sample_service.handle_aw_form_data.add' /] [atts callback_service='aw_form.callback-handler.career-form' /] [groups] [designer-details label='Designer Details'] [field dp_name label = "Name" type = "text" edit=yes parent_class='col-md-6' required=yes value='{app.dp_meta.name}' /] [field email label = "Email" type = "email" edit=yes parent_class='col-md-6' required=yes value='{app.dp_meta.email}' /] [field phone label = "Contact Number" type = "text" edit=yes parent_class='col-md-6' required=yes value='{app.dp_meta.phone}' /] [field select label = "Project Type" value="module.project_types" type = "text" edit=yes parent_class='col-md-6' required=yes value='{app.dp_meta.phone}' /] [/designer-details] [project-details label='Project Details'] [field false_ceiling label = "False Ceiling" type = "radio" edit=yes parent_class='col-md-6' required=yes /] [field special_finishes label = "Special Finishes" type = "textarea" edit=yes parent_class='col-md-6' required=yes /] [field any_other label = "Any Other" type = "textarea" edit=yes parent_class='col-md-6' required=yes /] [field date_of_visit label = "Date Of Visit" type = "date" edit=yes parent_class='col-md-6' required=yes /] [field time_of_visit label = "Time Of Visit" type = "time" edit=yes parent_class='col-md-6' required=yes /] [field pm_site_validation label = "Correction done as per PM's Site validation report" type = "radio" edit=yes parent_class='col-md-6' required=yes /] [/project-details] [attachments label='Attachments'] [field gfc_drawings label = "GFC Drawings" type = "text" edit=yes parent_class='col-md-6' required=yes /] [field electrical_drawings label = "Electrical Drawings" type = "text" edit=yes parent_class='col-md-6' required=yes /] [field site_validation_reportlabel = "Site Validation Report"type = "file_upload" allowed_file_types='pdf'app_name='dashboard'overwrite_file='no'edit=yesrequired=yes/] [/attachments] [/groups] [/sample-form] [/env.set_array] |
update_service
- Mention the service slug which will handle the form submission
- In this service do the server side validation and return the array if any error occured.
- To make server side validation works return the validation array with key as validations in which subarray contains key as meta_key and reason as error msg.
- You can use any content type service or collection service to handle the form submission eg: candidate, admission, lead
Ticket:
- This module is used to generate the redis ticket which is used in form handling.
- To generate the ticket use this:
-
12[aw_form.ticket.generate mod='module_name' tpl='template_name' service_type='service_name' topic='topic_name'form_config='form_config_array' /]
Single Submit:
- This module receives the ajax request from form submit handler
- The all request params array is then set in the single_data env variable
- The form_config of that form type is also set in the single_data variable
- The form name is also set in the single_data varable
- Then update service is fired which is mentioned in the single_data’s form_config variable
- Then update service Fired
- If update service gives validation error then these errors are returned as the javascript code which will show the error msg in the forms fields.
- It also populates the first error form control field.
- If any callback service is mentioned in the form_config then that service fired after the execution of the update service.
- If every thing is fine then final success msg is returned.
validation
- This module contents all the validation templates.
- Depends on the data_type of the filed, particular form validation ran.
- If the validation get failed then error msg returned with the validation error and field key.
Form Control2
- All the form fields which are mentioned in the form config gets the html from the form control2 service
Create
Call this module with the slug parameter of form which needs to be created.
To change the layout of the form fields just change the form_layout parameter.
usage:
1 |
[aw_form.create topic='career-form' form_layout=’left-label’ /] |