Scaffold generated UI and relationships

Just tried RedwoodsJS and so far loving it!

I have a newbie question about the best practices regarding relationships/foreign key representation in the UI. Scaffolding generates a form with a text field, and allows any value to be entered resulting in “Something went wrong” error message due to an invalid foreign key.

Is there a preferred way of dealing with this? A “type ahead” with a list of candidates, a selector or any other approach? Is this something that may be addressed in the scaffolding code in the future?

Also, are there any plans for allowing to “customize” scaffolding code generated by CLI - in form generation and possibly more?

Are you getting an invalid-foreign-key error even if you DO enter a valid foreign key? Or when you enter gibberish? If it’s the former, that would be bad—if your foreign key is an integer then it should be coercing to an integer before sending over GraphQL and to your service to be inserted into the database.

We don’t plan on adding a ton more to the scaffold generator in the near future, but if a PR came in that added some new functionality we would definitely be interested! These pages are meant to give you bare bones access to your model data and in most cases will be replaced with a more full-featured admin. If you’re just adding a couple of records for development here and there, looking up a foreign key is no big deal. But they weren’t meant for mass data insertion.

You can customize the generators (including scaffold) right now! Docs - CLI Commands : RedwoodJS Docs

Hi Rob,

Thank you for the response, much appreciated.

The error message appeared when a bad uuid key was entered, so there is no problem with framework and components.The difficulty for a new user like me is in setting expectations and in lack of clear understanding of what is generated by the framework with the purpose of building upon in further development, an what should be treated as a possible throwaway meant to be useful only initially or in a limited way. I think a good small but real life example (in the form of tutorial, or just code) of an admin app dealing with the typical things - role based menu, application level and per section layout, object lists with paging and a couple of forms covering real life cases would help a lot in adoption. I’d see it as the best practices “as envisioned” by the core team.

I will look into what can be done for extending scaffolding, thanks for the pointer.

1 Like

Talking about setting expectations… if you remember, how/where did you learn about generating scaffolds? Could we have had documentation around that resource explaining how we expect scaffolds to be used and what they do and don’t support (like the fact that foreign keys are just open text fields with no validation)?

If I remember correctly, it was through the tutorial. I may have overlooked a reference to the documentation, but overall I think the more references tutorial has - the better, as i think that many people use that as a starting point.