diff --git a/src/Fields/Field.php b/src/Fields/Field.php index f2b82e0ff8..d8563acf82 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -20,6 +20,7 @@ class Field implements Arrayable protected $parent; protected $parentField; protected $validationContext; + protected $form; public function __construct($handle, array $config) { @@ -409,4 +410,16 @@ public function isRelationship(): bool { return $this->fieldtype()->isRelationship(); } + + public function setForm($form) + { + $this->form = $form; + + return $this; + } + + public function form() + { + return $this->form; + } } diff --git a/src/Tags/Concerns/RendersForms.php b/src/Tags/Concerns/RendersForms.php index 28dbc9276e..f575b9c39f 100644 --- a/src/Tags/Concerns/RendersForms.php +++ b/src/Tags/Concerns/RendersForms.php @@ -127,6 +127,10 @@ protected function getRenderableField($field, $errorBag = 'default', $manipulate { $errors = session('errors') ? session('errors')->getBag($errorBag) : new MessageBag; + if (method_exists($this, 'form')) { + $field->setForm($this->form()); + } + $missing = str_random(); $old = old($field->handle(), $missing); $default = $field->value() ?? $field->defaultValue();