forcing values on a custom edit view form

43 views
Skip to first unread message

Chris Paschen

unread,
Oct 3, 2018, 8:35:30 PM10/3/18
to Joomla! General Development

I have an edit form on the front end for a custom component I'm buidling


When I need to create a new entry I just use the proper url to open the edit form and then save. All works fine
However, there are some occasions when I am jumping to that edit form from another view and need to pre-populate a value on that edit form based on the view I'm presently on, and I want to NOT allow the user to change that one field.

Not sure exactly how to do this.

I was thinking of just saving the value while on the original view as a session variable (because I need to do this with several forms throughout the site - all originating from that one form) or possibly via a parameter on the link used to get to the edit form, but not sure how to use that session variable to get the field set as needed on the edit form once the user arrives there.

Anyone have some tips or sample code you could share?

I've searched around but can't find anything that does quite this.
--
Chris Paschen
Paschen Communications, LLC

Chris Paschen, President

Paschen Communications, LLC

p: (651) 204-9218 | e: cpas...@paschencommunications.com
m: Box 9207, St. Paul, MN 55109
w: http://www.PaschenCommunications.com

View Chris Paschen's LinkedIn profile View Chris Paschen's profile

Follow @cpaschen

sentix

unread,
Oct 4, 2018, 7:27:11 AM10/4/18
to Joomla! General Development
Do you want to edit in backend (as part of joomlas own way to build the edit form) or in frontend (where you build the form by your own)?

MonkeyT

unread,
Oct 4, 2018, 8:22:43 AM10/4/18
to Joomla! General Development
If you are using Joomla's form object (creating the form as an object by using an XML definition file), you can bind/preload the value to the form item before it is displayed (a very common tactic when a form has been submitted with incomplete or invalid data) and then add an attribute to that form item to make it readonly.

llew...@vdm.io

unread,
Dec 2, 2018, 5:08:16 PM12/2/18
to Joomla! General Development
Hi Chris, have a look at this and let me know if this helps https://youtu.be/UVICsD82oWk

llew...@vdm.io

unread,
Dec 2, 2018, 6:55:37 PM12/2/18
to Joomla! General Development
Sorry I see I added how to setup a site view-form... to populate the fields with values are also easy. JCB has away to do this at least with one field out of the box. If you want to do more then one field you need only add a few lines of custom code, I made a tutorial about how to do this. Checkout this tutorial https://youtu.be/5hzkYODLIpU instead.
Reply all
Reply to author
Forward
0 new messages