Page 1 of 1

What is the best method to put default in a field ?

Posted: Wed Dec 01, 2021 11:37 pm
by yvesf
I would like to initiate a default value for a specific field that I can change when I am in the record.
What is the best method to do that ? directly in the database or in PHP ? how to do that also to put the today's date by default ? I have tried several methods without success unfortunately. Many thanks for your help

Re: What is the best method to put default in a field ?

Posted: Thu Dec 02, 2021 5:29 am
by kev1n
Hi,

To set a default value, use JavaScript in the form's Custom Code:
default_value.jpg
how to do that also to put the today's date by default
From the mySQL Reference:
Automatic Initialization and Updating for TIMESTAMP and DATETIME
TIMESTAMP and DATETIME columns can be automatically initializated and updated to the current date and time (that is, the current timestamp).
For any TIMESTAMP or DATETIME column in a table, you can assign the current timestamp as the default value, the auto-update value, or both:
An auto-initialized column is set to the current timestamp for inserted rows that specify no value for the column. Read more...
current_time_default.jpg