laravel-nova-nested-form icon indicating copy to clipboard operation
laravel-nova-nested-form copied to clipboard

How to pass a parameter to child nested form?

Open ValentynIpolitov opened this issue 4 years ago • 7 comments

Passing a parameter to nasted form:

My basic form has a select input with 2 options, depends on a chosen option i should use different riles in my nestedDFrm...so is it possible to get that select value and pass it ti my form?

There is the place i am adding the form:

NestedForm::make('DebtAllocations')->open(true)->min(1), HasMany::make('DebtAllocations'),

Here also i have currency option select added.

There is inside DebtAllocations form:

Number::make('Amount', 'amount')->onlyOnForms()->rules('required') And i need to set maximum posiible amount depends on currency - so for example, if currency is 'euro' the limit is 1000, but if currency is 'usd', the limit is 800

ValentynIpolitov avatar Jan 22 '21 19:01 ValentynIpolitov

Hi, I'm sorry, i'm not sure I understand what the issue is. If you're trying to set a maximum amount based on the given currency then I don't think the problem is related to this package, can you give me an example?

yassilah avatar Jan 22 '21 22:01 yassilah

I think you could use a custom validation rule, attached to nested form

alberto-bottarini avatar Jan 22 '21 22:01 alberto-bottarini

Hi, I'm sorry, i'm not sure I understand what the issue is. If you're trying to set a maximum amount based on the given currency then I don't think the problem is related to this package, can you give me an example?

There is an example: image

On the image above you can see that i chose ''EUR" as my currency. So in the debt allocation table below i should limit maximum amount to 800 eurs. In case i will choose "USD" instead of "EUR", the maximum amount will be 1000$ That what i am trying to do, but the problem is that i dont know how to get currency type(EUR or USD) to apply my validation rule in NestedForm::make('DebtAllocations'). Is it possible?

ValentynIpolitov avatar Jan 26 '21 21:01 ValentynIpolitov

Request::input("currency") ?

alberto-bottarini avatar Jan 27 '21 06:01 alberto-bottarini

@alberto-bottarini can you please elaborate?

tassilogroeper avatar Sep 29 '21 12:09 tassilogroeper

I think I was drunk. I do not remember what I intended

alberto-bottarini avatar Sep 29 '21 12:09 alberto-bottarini

I have the same issue: I want to pass data to the nested form. Is there a way to do that? It basically requires JS to do it. right?

tassilogroeper avatar Sep 29 '21 12:09 tassilogroeper