Closed chrillep closed 1 year ago
Hi, @chrillep
Our package is a wrapper on Nova Resources, that's why everything should work
ok ill try it
Hey @stepanenko3 ! Tested it, but cant get depends on fields to work :(
in app/Nova/Settings/Demo.php
<?php
declare(strict_types=1);
namespace App\Nova\Settings;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\FormData;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Stepanenko3\NovaSettings\Types\AbstractType;
class Demo extends AbstractType
{
public function fields(): array
{
return [
Boolean::make('Param 1 Show Text Field', 'param_1')
->default(true),
Text::make('Text That Param 1 Depends on', 'param_1_depends_on')
->hide()
->rules('sometimes')
->dependsOn('param_1', function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData->param_1 === false) {
$field->show()->rules('required');
}
}),
Select::make('Purchase Type', 'type')
->options([
'personal' => 'Personal',
'gift' => 'Gift',
]),
Text::make('Recipient')
->readonly()
->dependsOn(
['type'],
function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData->type === 'gift') {
$field->readonly(false)->rules(['required', 'email']);
}
}
),
];
}
}
@chrillep, thanks I will try to fix it in some days
@chrillep, thanks I will try to fix it in some days
really like your package tho. its just that depends on opens up alot of good ux for showing/hiding fields while editing :)
@stepanenko3 hey how is it going. Im guessing it is more work than expected (It always is) ;) . Keep up the good work tho!
@chrillep, hi Sorry for long delay Try this code
Because we are not able to update the attributes of already specified dependsOn, you must specify them explicitly
Select::make('Purchase Type', 'type')
->options([
'personal' => 'Personal',
'gift' => 'Gift',
]),
Text::make('Recipient')
->readonly()
->dependsOn(
['settings->type'],
function (Text $field, NovaRequest $request, FormData $formData) {
if ($formData->{'settings->type'} === 'gift') {
$field->readonly(false)->rules(['required', 'email']);
}
}
),
@chrillep
https://github.com/stepanenko3/nova-settings#using-dependson-with-out-package
eyyy gr8! ty!
does this package have dependsOn fields support?
https://nova.laravel.com/docs/4.0/resources/fields.html#dependent-fields
we are currently using outl1ne/nova-settings
but having issues with dependsOn fields not working. Or thats not fair. they just havent implemented dependson functionality
ref: