-
Notifications
You must be signed in to change notification settings - Fork 921
Add form component #5809
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
Open
pxpm
wants to merge
15
commits into
next
Choose a base branch
from
add-form-component
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add form component #5809
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
df6adc6
wip
pxpm b93bc1d
Apply fixes from StyleCI
StyleCIBot 1b77eb3
wip
pxpm ad0dd30
wip
pxpm d7e9792
Apply fixes from StyleCI
StyleCIBot 0479899
remove unused files
pxpm bf55a03
wip
pxpm 6ad70f9
Apply fixes from StyleCI
StyleCIBot 7cbc80b
wip
pxpm d8a05f7
Merge branch 'form-changes' into add-form-component
pxpm 5acaa03
modal body to have bg-light
tabacitu 9c02966
wip
pxpm b390e4a
fixes
pxpm 97e7ab6
Apply fixes from StyleCI
StyleCIBot 44b9fd4
Merge branch 'next' into add-form-component
tabacitu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tabacitu marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Backpack\CRUD\app\View\Components; | ||
|
||
use Backpack\CRUD\CrudManager; | ||
use Illuminate\View\Component; | ||
|
||
class Form extends Component | ||
{ | ||
public $crud; | ||
|
||
/** | ||
* Create a new component instance. | ||
* | ||
* @param string $controller The CRUD controller class name | ||
* @param string $operation The operation to use (create, update, etc.) | ||
* @param string|null $action Custom form action URL | ||
* @param string $method Form method (post, put, etc.) | ||
*/ | ||
public function __construct( | ||
public string $controller, | ||
public string $id = 'backpack-form', | ||
public string $operation = 'create', | ||
public ?string $action = null, | ||
public string $method = 'post', | ||
public bool $hasUploadFields = false, | ||
|
||
) { | ||
// Get CRUD panel instance from the controller | ||
if (CrudManager::hasCrudPanel($controller)) { | ||
$previousOperation = CrudManager::getCrudPanel($controller)->getOperation(); | ||
} | ||
|
||
$this->crud = CrudManager::setupCrudPanel($controller, $operation); | ||
|
||
if (isset($previousOperation)) { | ||
$this->crud->setOperation($previousOperation); | ||
} | ||
|
||
$this->operation = $operation; | ||
$this->action = $action ?? url($this->crud->route); | ||
$this->hasUploadFields = $this->crud->hasUploadFields($operation); | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
* | ||
* @return \Illuminate\Contracts\View\View|\Closure|string | ||
*/ | ||
public function render() | ||
{ | ||
return view('crud::components.form.form', [ | ||
'crud' => $this->crud, | ||
'saveAction' => $this->crud->getSaveAction(), | ||
'id' => $this->id, | ||
'operation' => $this->operation, | ||
'action' => $this->action, | ||
'method' => $this->method, | ||
]); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Backpack\CRUD\app\View\Components; | ||
|
||
class FormModal extends Form | ||
{ | ||
/** | ||
* Create a new component instance. | ||
* | ||
* @param string $controller The CRUD controller class name | ||
* @param string $operation The operation to use (create, update, etc.) | ||
* @param string|null $action Custom form action URL | ||
* @param string $method Form method (post, put, etc.) | ||
* @param string $modalTitle Title for the modal | ||
* @param string $modalClasses CSS classes for the modal dialog | ||
* @param string $formRouteOperation The operation to use for the form route (defaults to 'create') | ||
* @param string $id The ID for the form element (defaults to 'backpack-form') | ||
*/ | ||
public function __construct( | ||
public string $controller, | ||
public string $id = 'backpack-form', | ||
public string $operation = 'create', | ||
public string $formRouteOperation = 'create', | ||
public ?string $action = null, | ||
public string $method = 'post', | ||
public string $title = 'Form', | ||
public string $classes = 'modal-dialog modal-lg', | ||
public bool $refreshDatatable = false, | ||
) { | ||
parent::__construct($controller, $id, $operation, $action, $method); | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
* | ||
* @return \Illuminate\Contracts\View\View|\Closure|string | ||
*/ | ||
public function render() | ||
{ | ||
return view('crud::components.form.modal', [ | ||
'crud' => $this->crud, | ||
'id' => $this->id, | ||
'operation' => $this->operation, | ||
'formRouteOperation' => $this->formRouteOperation, | ||
'hasUploadFields' => $this->hasUploadFields, | ||
'refreshDatatable' => $this->refreshDatatable, | ||
'action' => $this->action, | ||
'method' => $this->method, | ||
'title' => $this->title, | ||
'classes' => $this->classes, | ||
]); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.