Documentation / Tutorials / Awesome Enterprise

AW Form Service

/ Awesome Enterprise / 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.
  • 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:

[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’ /]
[atts admin_email=’swapnil.k@amiworks.com’ /]
[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_report
label = “Site Validation Report”
type = “file_upload”
allowed_file_types=’pdf’
app_name=’dashboard’
overwrite_file=’no’
edit=yes
required=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:
  • [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:

[aw_form.create topic=’career-form’ form_layout=’left-label’ /]

 

Categories
Most Popular

Leave a Reply

Your email address will not be published. Required fields are marked *