Archived
generated from mitchell/rust_template
Add support for conditional rendering #12
No due date set.
Depends on
#19 Context
MarinoDev/leptos_form_tool
Reference: MarinoDev/leptos_form_tool#12
Reference in New Issue
Block a user
There should be a way to do conditional rendering. Like render components only if a certain condition is met, like age >= 18.
Perhaps this has something to do with the future implementation of groups.
Like a
<Show>. Could have a render when function added to all/some controls.Add support for Enum like renderingto Add support for conditional renderingThis gets tough when you consider the validation and what should happen on the server.
Do you validate fields that aren't showing? Do you validate them on the server? What if the context is different on the client and server? Will this lead to different validations (not good)?
If the validations always run and only the control is shown/hidden that would check all the boxes. However, if that validation fails, the form wouldn't submit and there would be no indication as to why.
If hidden controls don't validate, then we can't just blatantly add all the validations to a Vec and call it a day:
If it does depend on form data (needed for enum like rendering) we would need to store the validation functions along with their conditions to run.
Conditional Rendering implemented, but has hydration issues.
Most likely this is happening because no matter weather the show is true or not, we are still rendering the view, but then only showing the view within the show.
I think if we move the rendering of the view into the show, this should be solved???
Making the view a closure and moving that closure inside the show worked! Show When now works.
Lastly, we need to only run the validation if the component is showing
Conditional validation is now done