PHP code example of formfeed-uk / nova-dependable-panel
1. Go to this page and download the library: Download formfeed-uk/nova-dependable-panel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
formfeed-uk / nova-dependable-panel example snippets
use FormFeed\DependablePanel\DependablePanel;
public function fields(NovaRequest $request)
{
return [
Select::make('Select', 'select')->options([
'option1' => 'Option 1',
'option2' => 'Option 2',
]),
DependablePanel::make('Panel Title', [
Text::make('Field 1'),
Text::make('Field 2'),
])
->dependsOn(["select"], function (DependablePanel $panel, NovaRequest $request, FormData $formData) {
if ($formData['select'] == "option1") {
$panel->hide();
}
}),
];
}
use FormFeed\DependablePanel\DependablePanel;
public function fields(NovaRequest $request)
{
return [
DependablePanel::make('Panel Title', [
Select::make('Select', 'select')->options([
'option1' => 'Option 1',
'option2' => 'Option 2',
]),
Text::make('Hide Field 1')
->dependsOn(["select"], function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData['select'] == "option1") {
$field->hide();
}
}),
Text::make('Hide Field 2')
->dependsOn(["select"], function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData['select'] == "option1") {
$field->hide();
}
}),
Text::make('Show Field 3')
->hide()
->dependsOn(["select"], function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData['select'] == "option1") {
$field->show();
}
}),
Text::make('Show Field 4')
->hide()
->dependsOn(["select"], function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData['select'] == "option1") {
$field->show();
}
}),
])
->singleRequest(true);
];
}