Repository navigation
Expand file tree
/
Copy pathViewField.php
More file actions
71 lines (55 loc) · 1.39 KB
/
Copy pathViewField.php
File metadata and controls
71 lines (55 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
declare(strict_types=1);
namespace NyonCode\WireForms\Components\Display;
use Closure;
/**
* Display component that renders a custom Blade view.
*/
class ViewField extends Display
{
protected ?string $view = null;
/** @var array<string, mixed>|Closure */
protected array|Closure $viewData = [];
protected bool $isHtmlContent = false;
/** Set the Blade view that renders the field. */
public function view(string $view): static
{
$this->view = $view;
return $this;
}
/**
* Set the data passed to the view.
*
* @param array<string, mixed>|Closure $data
*/
public function viewData(array|Closure $data): static
{
$this->viewData = $data;
return $this;
}
/** Escape the content as text instead of rendering it as raw HTML. */
public function escape(bool $condition = true): static
{
$this->isHtmlContent = ! $condition;
return $this;
}
public function getView(): ?string
{
return $this->view;
}
/**
* @return array<string, mixed>
*/
public function getViewData(): array
{
return $this->evaluate($this->viewData);
}
public function isHtmlContent(): bool
{
return $this->isHtmlContent;
}
protected function viewName(): string
{
return 'wire-forms::components.view-field';
}
}