The todo_regdate is not initially filled with the date of today
The todo_regdate is not initially filled with the date of today, and should be read-only
There are different ways of doing this.
The first way is to define a rule at database level, so that when a field is inserted blank that it gets the default value.
The second method is to apply a rule to the field. To do this, select the DBTable component, open the fields propery and apply 'date_on_insert' to the forced value.
The third option is to set the default value of the field and make the field read-only.
To make a field read-only, select it in the form designer and set the read-only property. To set a default value, you can use the 'value' property of the field. But as the current date is a PHP function and is not static, you need to apply a line of PHP. The best event to do that is by using the onBeforeRender event of the registration date field:
Next, go to the PHP Events tab and open the onBeforeRender event:
This will open the PHP editor and apply
$this->value=date("Y-m-d");
As you are changing the value of the selected component itself, you can use $this->
If you want to change the value of another component user $$
For instance, you want a default deadline of 5 days after the registration date. To set this value you could add the following line in the onBeforeRender event of the deadline field:
$this->value=date('Y-m-d', strtotime($$todolist_todo_regdate->value.'+5 days'));
To make the registration date read-only:
Now you can generate and run the code:
- The