I wanted to make a simple shipping code generator. It has a fixed structure apart from the digit indicated by the red arrow, this digit should be the next record, ID, saved in the database. It should change for the next shipment. If there are 3 IDs in the database, it should be number 4.
The next time you save it, it will be number 5, and the next time you save it, it will be number 6. Do you know how to do it?
I hope I described it understandably?
The next time you save it, it will be number 5, and the next time you save it, it will be number 6. Do you know how to do it?
I hope I described it understandably?

you can count the saved records and create the string using PHP
Now you use the $totalCount variable to build the string, return it from the PHP action and use {var:php_action_name} in your field value
// Create a database object
$db = JFactory::getDbo();
// Table name
$tableName = $db->quoteName('your_table_name');
// SQL query to count records in the table
$query = $db->getQuery(true)
->select($db->quote('*'))
->from($tableName);
// Set the query for counting records
$query->select('COUNT(*) AS total');
// Execute the query
$db->setQuery($query);
try {
// Fetch the result as an associative array
$result = $db->loadAssoc();
// Extract the total count from the result
$totalCount = intval($result['total']);
// Output the total count
echo "Total records in $tableName: $totalCount";
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
Now you use the $totalCount variable to build the string, return it from the PHP action and use {var:php_action_name} in your field value
Where should I insert this code?
Do you have any screenshot instructions for Chronoforms 8 on how to do this?
your_table_name change to uw07j_chronoforms8_datalog ? This is the name of the table in which the form data is stored.
Do you mean to add code like this in the Value field?
1016 / 0000{var:php_action_name} / 24 / XX / GB
Do you have any screenshot instructions for Chronoforms 8 on how to do this?
your_table_name change to uw07j_chronoforms8_datalog ? This is the name of the table in which the form data is stored.
Do you mean to add code like this in the Value field?
1016 / 0000{var:php_action_name} / 24 / XX / GB

drag a PHP action above the Text field, insert the code and add this line at the end:
Then in your field value you should use {var:php_action_name}, replace "php_action_name" with the name of the PHP action you will drag
return $totalCount;
Then in your field value you should use {var:php_action_name}, replace "php_action_name" with the name of the PHP action you will drag
It worked, but there is this message from the front. Is this option paid Classic 1 domain 27.99?
actions/php can be used on the frontend after validating your install
actions/php can be used on the frontend after validating your install

The message means that PHP action can be used on the website frontend (public area) after validation, but for testing purposes you can run your test first:
1- in admin area, verify the code is working as expected
2- Enable the trial validation in the Chronoforms validation to test it further on the frontend
1- in admin area, verify the code is working as expected
2- Enable the trial validation in the Chronoforms validation to test it further on the frontend
One more very important thing: how to ensure that all text fields are impossible to edit by the user?
Currently, all text fields can be edited by the user. HTML atributes fields readonly is a good solution?
How do I clear test entries in this table? Is it enough to click EMPTY in phpmyadmin for this table and it will clear all test data and count from the beginning?
Currently, all text fields can be edited by the user. HTML atributes fields readonly is a good solution?
How do I clear test entries in this table? Is it enough to click EMPTY in phpmyadmin for this table and it will clear all test data and count from the beginning?
if you want to prevent editing then readonly is ok, but if this is sensitive data then you must build the data using PHP before the form is submitted.
You should TRUNCATE the table to reset the count, the feature is available in ChronoMyAdmin which can manage your Joomla database tables from the Joomla admin area
You should TRUNCATE the table to reset the count, the feature is available in ChronoMyAdmin which can manage your Joomla database tables from the Joomla admin area
Where in Chronoforms 8 are required fields set? Required to be completed. In previous versions of Chronoforms, I know it was more intuitive. I can't find it in the latest version of Chronoforms 8
You need to login to be able to post a reply.