1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\app\View\Components; |
4
|
|
|
|
5
|
|
|
class FormModal extends Form |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Create a new component instance. |
9
|
|
|
* |
10
|
|
|
* @param string $controller The CRUD controller class name |
11
|
|
|
* @param string $operation The operation to use (create, update, etc.) |
12
|
|
|
* @param string|null $action Custom form action URL |
13
|
|
|
* @param string $method Form method (post, put, etc.) |
14
|
|
|
* @param string $buttonText Text to display on the button that opens the modal |
15
|
|
|
* @param string $modalTitle Title for the modal |
16
|
|
|
* @param string $buttonClass CSS classes for the button |
17
|
|
|
*/ |
18
|
|
|
public function __construct( |
19
|
|
|
public string $controller, |
20
|
|
|
public string $operation = 'create', |
21
|
|
|
public ?string $action = null, |
22
|
|
|
public string $method = 'post', |
23
|
|
|
public string $buttonText = 'Open Form', |
24
|
|
|
public string $modalTitle = 'Form', |
25
|
|
|
public string $buttonClass = 'btn btn-primary' |
26
|
|
|
) { |
27
|
|
|
parent::__construct($controller, $operation, $action, $method); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get the view / contents that represent the component. |
32
|
|
|
* |
33
|
|
|
* @return \Illuminate\Contracts\View\View|\Closure|string |
34
|
|
|
*/ |
35
|
|
|
public function render() |
36
|
|
|
{ |
37
|
|
|
return view('crud::components.form.modal_form', [ |
38
|
|
|
'crud' => $this->crud, |
39
|
|
|
'operation' => $this->operation, |
40
|
|
|
'formAction' => $this->formAction, |
41
|
|
|
'formMethod' => $this->formMethod, |
42
|
|
|
'buttonText' => $this->buttonText, |
43
|
|
|
'modalTitle' => $this->modalTitle, |
44
|
|
|
'buttonClass' => $this->buttonClass, |
45
|
|
|
]); |
46
|
|
|
} |
47
|
|
|
} |