Is it possible to map a Date field to Events start field (which is of type DateTime). If not: Is it possible to have use a widget for DateTime that only shows 'Date'. ( If possible, I would prefer to avoid hiding the 'time part' with CSS).
It is possible to map a Date field to a DateTime field by setting a default value for the time part. The exact implementation may vary depending on the language or framework used. However, if you prefer to display and select only the date part without the time component, you can use a date picker widget.
Examples include HTML5's <input type="date">
element and JavaScript libraries like jQuery UI, Bootstrap Datepicker, or Flatpickr. Utilizing a date picker eliminates the need for CSS manipulation to hide the time part.
Hi
I have some python code that can do this, but I was hoping there was a way to do it 'directly in Easyform'.
I was hoping it was possible to do this 'with python', so something like this (not working… dato is the Easyform Date field and 'start' is the Event's start field):
python:datetime(dato) start
You can use Python code to map a Date field to an Event's start field directly. By utilizing the datetime.combine()
function, you can convert the Date field value to a datetime object with a default time component. This allows you to assign the converted value to the Event's start field. This approach enables you to achieve the desired mapping without relying on external libraries or complex workarounds.
Like:
python:
from datetime import datetime
Assuming 'dato' is the Easyform Date field value
dato_value = dato
Convert the date value to a datetime object
start_value = datetime.combine(dato_value, datetime.min.time())
Assign the converted value to the Event's start field
start = start_value