Open ExFredrik opened 4 years ago
Is there any update for this?
The interesting thing is that the code should handle any property as the column name is saved as $dependency['property']}
.
Regardless, it only works for the primary key. Maybe it's some restriction on what the frontend can "see" about the resource being edited?
Looking for this.
If the PR above is merged, you'll soon be able to reference BelongsTo fields like so:
NovaDependencyContainer::make([
Boolean::make('Admin')
])->dependsOn('user.type', 'admin');
As a workaround I have made a change to allow using array as dependsOn
value. And I use it to bypass this issue like so:
public function fields(Request $request)
{
return $this->superchargeFields(
[
BelongsTo::make('AWX Variable', 'awx_variable'),
NovaDependencyContainer::make([Text::make('Value')])
->dependsOnArray(
'awx_variable.id',
AwxVariable::where('var_type', 'text')->pluck('id')->toArray()
),
NovaDependencyContainer::make([TextArea::make('Value')])
->dependsOnArray(
'awx_variable.id',
AwxVariable::where('var_type', 'textarea')->pluck('id')->toArray()
),
NovaDependencyContainer::make([Number::make('Value')])
->dependsOnArray(
'awx_variable.id',
AwxVariable::where('var_type', 'number')->pluck('id')->toArray()
),
...
]
}
Check this release : https://github.com/mathieufrh/nova-dependency-container/releases/tag/1.3.6
I'm trying to create an dependancy based on a string-value from a BelongsTo-table. Is this supposed to work or are there any possible sollutions for this?
Similiar to issue: #114
Code example: BelongsTo::make('Produkt', 'product', 'App\Nova\Product'),
NovaDependencyContainer::make([ Date::make('Startdatum', 'start_date')
]) ->dependsOn('product.StringCollumn', 'ValueOfStringCollumn')