ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

The Id number in the text field automatically changes each time it is sent

sylwekb 30 Jan, 2024
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?

https://wysylki.piwtomaszowmaz.pl/id_text_fileld.jpg
Max_admin 29d ago
you can count the saved records and create the string using PHP

// 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
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
sylwekb 29d ago
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
https://wysylki.piwtomaszowmaz.pl/var.jpg
Max_admin 29d ago
drag a PHP action above the Text field, insert the code and add this line at the end:
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
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
sylwekb 29d ago
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

https://wysylki.piwtomaszowmaz.pl/action.jpg
Max_admin 29d ago
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
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
sylwekb 29d ago
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?
Max_admin 29d ago
Answer
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
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
sylwekb 23d ago
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
sylwekb 23d ago
1 Likes
I already found it on the Behaviors, on my small screen I have to swipe down a lot to find these functions. I'm sorry for the trouble.
You need to login to be able to post a reply.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com