In this tutorial, we'll cover how to add a digit field to your forms. This method allows you to integrate digit-only inputs seamlessly into your application forms. This method takes three parameters:
This example shows how to add a digit field.
// Adding a digit field
$objConfig->digit('field_name', 'field_label', $required = 0);
To configure the digit field to only allow numbers up to a certain maximum value, you can chain the max()
method after the digit()
method. This example shows how to add a digit field that allows only numbers between 0 and 999.
// Adding a digit field with a max value of 999
$objConfig->digit('field_name', 'field_label', $required = 1)->max(3);
In this example:
For the configuration to work properly, it's important to include the 'field_name'
amongst the `addFields` and `editFields`
. This ensures that the digit fields are correctly initialized and integrated into your form. This example shows how to configure the add and edit fields.
// Adding your digit field to the add and edit forms
$objConfig->addFields(array('field_name'));
$objConfig->editFields(array('field_name'));
By following these steps, you can easily integrate digit fields into your forms using $objConfig->digit('field_name', 'field_label', $required = 0);
. We also covered how to configure the digit field to only allow numbers up to a certain maximum value using $objConfig->digit('field_name', 'field_label', $required = 0)->max(3);
.
Your download is here.