Skip to content

Consolidate form fields into one partial#18

Merged
ryanmitchell merged 12 commits intomainfrom
fix/forms
Nov 25, 2024
Merged

Consolidate form fields into one partial#18
ryanmitchell merged 12 commits intomainfrom
fix/forms

Conversation

@ryanmitchell
Copy link
Copy Markdown
Contributor

@ryanmitchell ryanmitchell commented Aug 15, 2024

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.

@ryanmitchell ryanmitchell marked this pull request as ready for review August 15, 2024 16:06
@ryanmitchell
Copy link
Copy Markdown
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.

@anditopping
Copy link
Copy Markdown
Contributor

Seems to work well. I'll hold off pushing until you're happy.

@anditopping
Copy link
Copy Markdown
Contributor

Happy to merge?

@ryanmitchell
Copy link
Copy Markdown
Contributor Author

Waiting for Gareth to run through MPEL to be sure it doest need further changes.

@ryanmitchell ryanmitchell merged commit 386818f into main Nov 25, 2024
@ryanmitchell ryanmitchell deleted the fix/forms branch November 25, 2024 09:39
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

Successfully merging this pull request may close these issues.

2 participants