Having problems with a custom account creation form in Rails #350
Replies: 2 comments
-
Given that you're submitting them to the same Rodauth action, I would recommend using the same form template for Authors and Users, but generating different fields based on a query parameter. For example, you could generate link |
Beta Was this translation helpful? Give feedback.
-
This is a sensible approach, thank you, Janko! Thank you! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, so I've been fighting this problem with Rodauth for a few hours now, and I would like to get some suggestions from more experienced Rodauth users out there.
I need a separate, multi-step form for my app's Author's (differs from a normal User by a few additional fields).
For that, I created a custom
RodauthController
with acreate-author-account
action and a view with my custom form.In order to keep it simple (or so I though initially), I point this custom Author form action to the default Rodauth create account path (
rodauth.create_account_path
).And then, in the
RodauthMain
inbefore_create_account
andafter_create_account
I handle the difference between these two types of users, and forms, accordingly.Despite this being maybe a little bit ugly from the code design perspective - it works for me. For the happy path, that is.
The problem starts when the Author form is invalid upon submission. It re-renders the original Rodauth account creation form, which is designed for sign up for regular User in my app. It doesn't re-render the Author custom form with the errors. And why would it? It does know nothing about it.
How do I make this work, though? Should I keep the current design and somehow manipulate Rodauth to re-render my Author custom form if there are errors? How can I do it?
Or should I approach it differently? How then?
Thank you a lot for your suggestions!
Beta Was this translation helpful? Give feedback.
All reactions