Open anilkreddy opened 6 years ago
looking at this question, are you using the trait?
looking at this question, are you using the trait?
Seems I already have this issue raised, today when I tried the same thing, it still doesn't work for me.
Yes, I have the trait in the model,
I have use FormAccessible
protected $fillable = [
'title', 'firstname', 'lastname', 'date_of_birth'
];
protected $dates = [
'date_of_birth',
];
public function formDateOfBirthAttribute($date)
{
return Carbon::parse($value)->format('d-m-Y');
}`
And the form field is
{!! Form::text('profile[date_of_birth]', null, ['placeholder' => 'dd/mm/yyyy', 'class' => 'js-datepicker form-control', 'data-date-format' => 'dd/mm/yyyy']); !!}
What if your model did the date conversion?
What if your model did the date conversion? Sorry, I'm not clear. How do I do that?
The docs says you can have a $dateFormat
property in case your date format it's different from the usual Y-m-d.
There's also Mutators and Accesors; you define functions to retrieve and format data from a column and you can also modify it before saving it.
Is the generator not reading through eloquent's casting rules? I have some models that cast fields to date with a specific format but I still get datetime in the value outputted by the generator.
Hi, I have a form with a date field, I have written form model accessors but the value is still not changing.
<input type="text" id="birthdate" name="profile[birthdate]" value="12/05/1991">
Here the date format is in (m/d/Y) but required format is (d/m/Y)
And the form model accessor defined in Model Profile model is,