Skip to content

Commit ee7b6d8

Browse files
committed
fix
1 parent 7e22ea3 commit ee7b6d8

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/Fields/Field.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ public function value(?Closure $callback = null): static
467467
public function hydrateFromRequest(Request $request, Model $model): void
468468
{
469469
once(function () use ($request, $model): void {
470-
if (in_array($request->method(), ['POST', 'PATCH']) && $request->isTurboFrameRequest()) {
470+
if (
471+
in_array($request->method(), ['POST', 'PATCH'])
472+
&& $request->isTurboFrameRequest()
473+
&& $request->has($this->getRequestKey())
474+
) {
471475
$this->resolveHydrate($request, $model, $this->getValueForHydrate($request));
472476
} elseif ($this->withOldValue && $request->session()->hasOldInput($this->getRequestKey())) {
473477
$this->resolveHydrate($request, $model, $this->getOldValue($request));

src/Fields/Repeater.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ public function withFields(Closure $callback): static
149149
$field->setModelAttribute($attribute)
150150
->name($attribute)
151151
->id($attribute)
152-
->value(fn (): mixed => $tmpModel->getAttribute($key));
152+
->when($tmpModel->hasAttribute($key), function (Field $field) use ($tmpModel, $key): void {
153+
$field->value(fn (): mixed => $tmpModel->getAttribute($key));
154+
});
153155
});
154156

155157
return $fields;
@@ -179,7 +181,7 @@ public function newTemporaryModel(array $attributes = []): Model
179181
};
180182

181183
return $model->forceFill(array_replace(
182-
['_key' => Str::uuid()],
184+
['_key' => Str::uuid()->toString()],
183185
$attributes
184186
));
185187
}
@@ -217,10 +219,12 @@ public function resolveFormat(Request $request, Model $model): ?string
217219
{
218220
if (is_null($this->formatResolver)) {
219221
$this->formatResolver = function (Request $request, Model $model, ?array $value = null): string {
220-
$values = array_map(fn (array $value): array => $this->resolveOptionFields($request, $model, $this->newTemporaryModel($value))
221-
->authorized($request, $model)
222-
->visible('show')
223-
->mapToDisplay($request, $model), (array) $value);
222+
$values = array_map(function (array $value) use ($request, $model): array {
223+
return $this->resolveOptionFields($request, $model, $this->newTemporaryModel($value))
224+
->authorized($request, $model)
225+
->visible('show')
226+
->mapToDisplay($request, $model);
227+
}, (array) $value);
224228

225229
return View::make('root::fields.repeater-table', ['values' => $values])->render();
226230
};

0 commit comments

Comments
 (0)