User is redirected to a page displaying all the New Things Fields
So far, so good.
What I don’t understand how to do:
(On the page displaying all the fields)
User clicks “EDIT”
Text blocks are transformed into Inputs
User modifies fields
User clicks “SAVE”
Changes to the Thing are made
Inputs go back to text blocks.
The easy way to do this would be to redirect user to an Edit page when clicking edit, and that page would contain the initial form but the Thing would be called and fields would be pre-filled.
But I’d like the user to be able to do this all on the same page.
I guess I need to use custom states but I can’t get my head around how to.
You duplicate the elements (text and input) and you alternate the visibility between them.
You use the same input element for both things and with conditionals you change the style and disable the input(to view).
You can do this via parameter, custom state or whatever other thing you come up with. Just make sure you are taking care of permissions while doing this.
In relation to my second option and @romanmg video as both use the same approach.
Make sure you are handling security on a server workflow. This is not covered by the video.
If the user shouldn’t be able to edit you shouldn’t let him run the “make change to a thing workflow”. So use “only when” condition.
Do not rely exclusively on the disabled input(or hiding/showing elements) because it(they) can be enabled on the client side very easily.
Not the best as it is quite erratic at some points. There are several posts about this.
Sometimes there is a delay between the render of the page and the redirect so someone not logged in can see the contents and the source of the page.
If you are basing all security on “logged in” because you only have one type of user(this is logged in user) you may as well add to any create/edit/delete workflow the condition “only when user is logged in”.