dateTimeType got now() as default value
# 2 years, 4 months ago
I have several datetime field. Everything is working perfectly but for one tiny detail.
I don’t want the default value as now() in these fields. Maybe in some of them but not all.
I cannot find where, this default value, apply to the form field.
Cab u help?
# 2 years, 3 months ago
actually I found that in this file
in both update and create Entity, there were this mechanism.
I think this was the instruction:
This is within a foreach, working all the entity attributes.
Since I cannot find setAttributes function I UNSET the attributes I don’t want to be forcibly set (only if they are null in the first instance):1234if($attributes['occurred']==null)unset($entity->occurred);if($attributes['verified']==null)unset($entity->verified);if($attributes['video_start']==null)unset($entity->video_start);if($attributes['video_end']==null)unset($entity->video_end);
I also add this code:123456789$user = \Auth::user();$datetime=$entity->created_at;$datetime->setTimezone($user->time_zone);$entity->created_at=$datetime;$datetime=$entity->updated_at;$datetime->setTimezone($user->time_zone);$entity->updated_at=$datetime;
I needed to have created_at and updated_at in the user timezone.
# 1 year, 9 months ago
I am reopening this issue because I have not solved it so far.
the mechanism I wrote about, in Platform/Core directory, was correct. In that way I can modify a form field during the save phase.
But, this issue was originally different.
What I mean exactly is that when I click a dateType field in a form, a calendar open (and it’s correct) and the current date appear into the field.
I don’t want the current date to appear into the field.
How can I prevent that ?
Thank you and have a nice new year 🙂
# 1 year, 9 months ago
I solved the issue.
I find in Entities, regarding the field I have the issue on, this code:
* Required to proper parse date provided in user date format
* @param $value
public function setclosingDateAttribute($value)
$parsed = Carbon::parse($value);
$this->attributes[‘closing_date’] = $parsed;
I got rid of the Carbon thing, setting $parsed to $value and I got what I wanted 🙂
Do you think this would be correct ?
Thank you for your help
You must be logged in to reply to this topic.