-
Notifications
You must be signed in to change notification settings - Fork 94
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
Adds support for conditional steps #171
Conversation
Drafting pending review from @jessarcher |
Should this instead be something like |
Is this something I should answer? This is my first PR :) I am happy to implement the suggested change. |
He's asking a general question, to all PR participants (including you), and also to the main maintainer, @jessarcher |
Having the condition as the first argument reads nicely. I think the ultimate API would be a $responses = form()
->text('First question...')
->when($condition, fn ($form) => $form
->text('Conditional question')
->text('Another conditional question')
); But I had a quick play around and it's not straight-forward to implement with the revert behavior. |
Following your reasoning Taylor why isn't addScrollable (because scroll is also an option) added? Having each optional parameter in a function would create a cartesian product. And with the option to use named arguments I don't see the need for moving the condition to the first argument (and remove the optional behaviour). How do we advance in this? Jess is trying to implement the same effect with another solution. |
I'd say it's because the conditional aspect, when present, is important to read before the specific configuration of the step. It follows the way a typical
I think Taylor would be happy to merge if you added a new |
I implemented the new method and changed the test cases. Please review :) |
In pull request #118 revertable forms is introduced. I found no proper way to make steps conditional to the answer of the previous steps. The
$step
closure seems to be an option. But then reverting does not work.See the example below:
The option
ignoreWhenReverting
seems to be an option, but it that simply skips the step. So conditional forms are hard.In the example below I rewrote the above example with the suggested change. And now everything seems to work fine.