HomeDocumentationTutorialsIncluding a clean text field in your module

Including a clean text field in your module

Overview

In this tutorial, we'll cover how to add a clean text field to your forms using a method from your configuration object, $objConfig->cleanText('field_name', 'field_label', $required = 0);. This method allows you to integrate text inputs that are sanitized and validated, ensuring that the text data submitted is clean and secure.

 

This method adds a clean text input field to your form, taking three parameters:

 

  • field_name: The name attribute for the clean text input.
  • field_label: The label that will be displayed alongside the clean text input.
  • $required: An optional parameter (default is 0) that specifies whether the clean text input is required (1) or not (0).

 

Here's a sample code to include a clean text field to your form;

 

PHP
 // Adding a required clean text field
$objConfig->cleanText('field_name', 'field_label', $required = 1);

 

Configuration in Your Application

For the configuration to work properly, it's important to include the 'field_name' amongst the addFields and editFields. This ensures that the clean text fields are correctly initialized and integrated into your form. This example shows how to configure the add and edit fields.

 

PHP
// Adding your clean text field to the add and edit forms
$objConfig->addFields(array('field_name'));
$objConfig->editFields(array('field_name'));

 

Conclusion

By following these steps, you can easily integrate clean text fields into your forms using $objConfig->cleanText('field_name', 'field_label', $required = 0);. This method ensures that the text input is sanitized and validated, providing a secure and user-friendly form experience.