When generating live views through phx.gen.live the entire set of table, schema and corresponding liveviews (.ex and heex), router links are generated with a default id field that is not even visually present in the schema definition.
I wonder if there a setting of a flag that lets me specify the name of that ‘id’ name with me custom name, like. ‘country_id’, ‘product_id’ or similar so I don’t need to manually search and rename all the instances of it to change it. Thanks
If you want to have them now, or want to use your own templates, you can create a file for each template in priv/templates/phx.gen.live/ with your custom template code.
Thanks. This is very new to me.
How would it work, I would change the default “id” for what I need only inside the “live” templates, but not inside the “context”?
And if I need to create various different views, then I’d need to create a template by template and change the field before each new generation?
Is that it?
Sorry, after re-reading your question, I realize that my answer does not solve what you are asking. I thought you only wanted to change the routes in the Heex templates.
To be honest, maybe I do want to change it only in HEEX as my final objective is to use it in url params. I thought to do it properly I’d need to change it everywhere, but I think your option of using Phoenix.Params might indeed be enough for my use case. Thanks.