I’m a newbie here and I’ve stuck. I would like to create temporary attributes in forms, but don’t know how. To be more specific:
I have a database column that represents 24-hour time, HH:MM:SS format. In a view file, form is made of 2 text fields, one is 12-hour representation of hours and the other one of minutes, and one dropdown menu with am/pm options. When the 24-hour is converted to 12-hour time in PHP, how to display those values in the view file using model? Also, how to gather those 3 attributes when saving into one and to save it?
(I have 28 24-hour columns and I’m trying to avoid 28*3 columns)
In the form create/update you can put the fulltime parts from $_POST together and assign the full time to your db-attribute.
//build the value for the db-field something like this
//hour, minute, second are your virtual attributes
//you can add a method 'setTimeFromPOST' to the model for this
$model->fullTime = mktime($_POST['hour'],$_POST['minute'],$_POST['second']);