I have table project with fields of “full_date” in format YYYY-MM-DD and “year” in format YYYY.
So what to do when I enter date in field “full_date“, it will automatic field-in data in field “year” in format YYYY ?
To automatically fill the “year” field based on the “full_date” field in PHPRUNNER, you can use a custom event. Here’s a step-by-step guide to achieve this:
- Open your project in PHPRUNNER.
- Navigate to the Events tab.
- Select the appropriate event where you want to add the custom code. For this scenario, you can use the
Before record addedorBefore record updatedevent. - Add the following custom code to extract the year from the “full_date” and set it to the “year” field:
// Extract the year from the full_date field
$values["year"] = date("Y", strtotime($values["full_date"]));