New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False update value from date picker in repeaters #745
Comments
Confirming that we are also running into this issue. We are storing We are working around it using mutators, e.g. like this: <?php
namespace App\Helpers;
use Carbon\Carbon;
class DateHelpers
{
public static function stripTime($value)
{
if (!$value) {
return;
}
if (!is_string($value)) {
return;
}
return (new Carbon($value))
->setTime(0, 0, 0)
->toDateTimeString();
}
} <?php
namespace App\Models;
use App\Helpers\DateHelpers;
class DateRule
{
protected $dates = ['test_date'];
public function setTestDateAttribute($value)
{
$this->attributes['test_date'] = DateHelpers::stripTime($value);
}
public function getTestDateAttribute()
{
return DateHelpers::stripTime($this->attributes['test_date']);
}
} |
Hi @galingong and @IllyaMoskvin, thanks for reporting this issue. I started investigating this today and was able to reproduce it following the steps described. If I understand correctly, using
I'm not really sure but I think the bug is caused by Let me know if this makes any sense. I'll keep testing :) |
Small update on casting. The following two are equivalent (they cause the issue described with a
And this saves the selected time to the DB column but will reset it to
|
This should be resolved in 3.x with: #1724 |
Date picker would save different values than displayed when used in repeaters outside the block editor (i.e. one-to-many).
For the bug the be present, all of these 3 things has to be true: Timezone is not UTC, child model has $dates attribute set, date field is in a repeater.
Steps to reproduce:
foreignId
column (parent_id
) and adatetime
column (test_date
)public $repeaters = ['children']
), create a repeater blade for the children (it should have a date_picker field fortest_date
), and add a repeater formField type children to the parent.protected $dates = ['test_date'];
should be set. Timezone in configapp.timezone
has to be something different than UTC (e.g.Europe/Paris
).Here's a screencast displaying the issue: https://drive.google.com/file/d/1YwfAL2ZcXq8Q2Taf7lcTg-8YX2cKCZL7/view?usp=sharing
The text was updated successfully, but these errors were encountered: