Consolidate form fields into one partial#18
Merged
ryanmitchell merged 12 commits intomainfrom Nov 25, 2024
Merged
Conversation
Contributor
Author
|
@anditopping can you give this a once over and a test to be sure it does what you need. I havent really thought about non livewire or precognition that seriously, but I guess we dont do that so much any more. |
Contributor
|
Seems to work well. I'll hold off pushing until you're happy. |
Contributor
|
Happy to merge? |
Contributor
Author
|
Waiting for Gareth to run through MPEL to be sure it doest need further changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR consolidates the form field partials into one component and shares layout where possible.
It introduces the concept of a 'driver' (either 'precognition', 'livewire' or blank) so the appropriate code is loaded depending on the context the are used.
The fields loop should now become something like this for precognition:
{{ fields }} {{ partial:if_exists src="_partials/forms/fields/{{ type }}" driver="precognition" }} {{ /fields }}or this for livewire (model_prefix is the path to the model we're updating, eg
data.):{{ fields }} {{ partial:if_exists src="_partials/forms/fields/{{ type }}" driver="livewire" model_prefix="data." }} {{ /fields }}I've split the label and before instruction out into their own partial, and the error and below instructions into their own. Let's make life easier for Jess.
If you want to show the labels, then:
{{ fields }} {{ partial:if_exists src="_partials/forms/fields/{{ type }}" show_label="true" }} {{ /fields }}Left as a PR as I need to still consider field ids/errors/instruction references when nested inside replicators.