Skip to content
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

How to pass a parameter to child nested form? #127

Open
ValentynIpolitov opened this issue Jan 22, 2021 · 7 comments
Open

How to pass a parameter to child nested form? #127

ValentynIpolitov opened this issue Jan 22, 2021 · 7 comments

Comments

@ValentynIpolitov
Copy link

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

@yassilah
Copy link
Owner

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?

@alberto-bottarini
Copy link
Collaborator

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

@ValentynIpolitov
Copy link
Author

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?

@alberto-bottarini
Copy link
Collaborator

Request::input("currency") ?

@tassilogroeper
Copy link

@alberto-bottarini can you please elaborate?

@alberto-bottarini
Copy link
Collaborator

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

@tassilogroeper
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants