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

required field handling #9

Open
teichsta opened this issue Jun 3, 2022 · 6 comments
Open

required field handling #9

teichsta opened this issue Jun 3, 2022 · 6 comments

Comments

@teichsta
Copy link

teichsta commented Jun 3, 2022

Hi,

thanks for providing this great plugin! I am wondering if there is a way to deal with required fields like in kirby itself. If a required field is hidden a page is considered "valid". While whenQuery doesn't seem to take this into account. Even hidden fields are evaluated while changing the pages state, correct?

Is there a way around it?

Best, Thomas E.-E.

@rasteiner
Copy link
Owner

In theory this plugin should behave exactly like the when property of standard Kirby, since it overrides the function that when uses (the meetsCondition function). It doesn't actually actively "hide" sections and fields, it just answers the question whether a field should be hidden or not. That's why I find it really strange that it behaves differently from the normal when.

Could you provide an example blueprint?

@quentin-f451
Copy link

Hi,
I do have the same problem with required fields when they are hidden. Here is a simplified example:

category:
  type: checkboxes
  options:
    value1: Value 1
    value2: Value 2
firstTitle:
  type: text
  required: true
  whenQuery: category ::any($ = "value1")
secondTitle:
  type: text
  required: true
  whenQuery: category ::any($ = "value2")

If I only select value1 in the category fields, I still have an alert if secondTitle (that is hidden) is empty.

@teichsta
Copy link
Author

teichsta commented Jul 7, 2022

does this example help @rasteiner ?

@rasteiner
Copy link
Owner

rasteiner commented Jul 7, 2022

Yes, sorry. I was swallowed by deadlines.
It seems like kirby also checks on the serverside if a field is required or not.

This makes it much more difficult, because the query can currently only be evaluated in the browser. Also, I don't believe I can change the serverside code in any way from a plugin.

So, currently I have no idea how I could fix this.

@moritzpflueger
Copy link

I have the same issue using kirby v4.

@rasteiner
Copy link
Owner

rasteiner commented Apr 22, 2024

Unfortunately the situation in Kirby 4 has not changed. There is no reasonable way to extend this behaviour in Kirby. Even if I'd implement the query parser in server side code, there is no way I could make Kirby use it.

The only solution would be to integrate this functionality into Kirby core; I already asked the team about this and there doesn't seem to be much interest in accepting such a pull request.

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