HomeDocumentationTutorialsIncluding a Yes-No field in my form

Including a Yes-No field in my form

Overview

In this tutorial, we'll cover how to add a yes-no field to your forms. This method allows you to integrate yes-no (boolean) inputs seamlessly into your application forms.  This method takes three parameters:

 

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

 

This example shows how to add a yes-no field.

 

PHP
// Adding a yes-no field
$objConfig->yesno('field_name', 'field_label', $required = 0);

 

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 fields are correctly initialized and integrated into your form. This example shows how to configure the add and edit fields.

 

PHP
// Adding your yes-no 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 yes-no fields into your PHP forms using $objConfig->yesno('field_name', 'field_label', $required = 0);. This method provides flexibility in configuring yes-no inputs according to your application's needs.