Hello gms,
1: it is possible to have the field pre-selected and hidden.
In the field configuration, tab 'Basic Options' you have to make the following settings:
Option 'Preselect solitary option' = 'True'
Option 'Hide when preselected' = 'True'
Your solution works well and is probably sufficient for you.
The solution with a 'Visforms Custom Plugin'
- would be the technically safe option and
- requires little code.
2: A technically safe option means here:
The next record ID to be assigned is fetched 'early'.
However, if the form is sent 'late', the next data record ID to be assigned may already be different because other forms have been sent by other users in the meantime.
In such a case, the redirection would be to another user's data.
In a 'Visforms Custom Plugin', however, you can access the data record ID that is actually used.
3: The secure SQL statement looks like this.
Code:
select ifnull(max(id),0) + 1 as label, ifnull(max(id),0) + 1 as value from #__visforms_[form-id];
This SQL statement also works for the very first submission of the form if there is no data in the data table yet.
In this case the SQL function max() would return 'null'.
And a 'null + 1' would also return a 'null', i.e. not 1 and there would be an error in the redirect URL.
SQL max() function with null values:
www.w3resource.com/sql/aggregate-functio...with_null_values.php
MySQL IFNULL() Function:
www.w3schools.com/sql/func_mysql_ifnull.asp
4: We think your requirement is a good addition to the existing options for a redirect as a simple configuration.
I have created an issue for development in the wish list:
Issue [VF-1004] Forum: Redirect after Form Submit: Add Option: Redirect to detail-view of submitted form data
When we release the new feature, you will be explicitly informed about the release here in the topic.
Thank you again for your contribution!
Kind regards, Ingmar