Hi
Some time ago I built a form for Joomla user registration, and placed additional user fields in the Users table. I was advised against this, so created a seceond table and related it to Users, ie one user can have many additional fields. This registration form works fine, records saved properly to both tables.
Then created a duplicate form so a user can update their registration data. So a logged in user opens the form and it opens for that user and it shows their data.
Now getting back to when I first had all the additional fields in the Users table, I find I cannot delete them otherwise get an "unknown column in the fields list " error. Haven't figure solution for this so have left them in.
Problem is that the update saves the addiotal fields to the Users table and can't figure why.
Have 2 save actions - one for the Users table and one for the other table. Have left the Data Provider blank and in the three Data Overrides boxes have inserted for eg
Users tabgle => name {data:name} update
Related table => city {data:city} update
The text field boxes are called name and city so their names correspond to the save action names.
What am I dong wrong?
Thanks
need to delete Chronoforms cache after you make changes to your table
Change the database table, fix your read / save data actions, then clear cache.
And make sure you don't have auto manage data table switched on for any save data actions involving core tables.
When u say change the database table do u mean delete the additional fields in the Users table?
I've done something wrong, cant get into site backend. Get redirected to frontend.
Renamed cityyy back to city, no go.
Will install backup later today.
Wonder if this has something to do with the fields table, the new functionality that Max recently added. Before I added my own related table I did use the new fields function and it does have city etc fields with values. This must be the unknown column in field list. When I restore I'll delete those values
Did you add columns to that as well
Don't really recall but looks like I must have
OK running again.
Re updating the users table do you use the save user or the save data action
Save data. Save user is for adding a new user to the table ONLY and includes hashing the password.
Had a new mishap . Not sure what I did but all the user names, usernames and emails were changed to {name}, {username} and {email}. Then couldn't log in. So back to restore. Will have to try recreate this so don't slip up like this on live site. Chrono is one challenging extension.
What I'm trying to do is create a copy of a working Joomla registration form, built on 2 tables (the reg form works).
Then present the copy, with all field values showing , to the logged in user so that he/she can edit their registration profile.
Well you want {data: fieldname} to use the data entered into a field. And you want to only update where user id is {user:id}
So in Data Overrides for the users table => fieldname {data:fieldname} on update
And then in Update conditions => id (pk) = {user:id} Use
In Data Overrides for the related table => fieldname {data:fieldname} on update
And then in Update conditions => userid (foreign key) = {user:id} Use
In the update conditions is the = an assignment or is it equal?
I mean.... that SOUNDS right. Take a database dump and try it out. Use snag.gy and post a screenshot of your settings just to be sure
Just working on the users table, the update form is updating the values in the name and email fields. So the Connectivity table list shows the updated values, good.
But when opening the update form for say editing the name value again, it shows the old values. Not sure why because read data points to the users table and the name and email values have been updated. Have cleared cache etc so not that.
https://snag.gy/Y5EN7h.jpg
https://snag.gy/4CY5yl.jpg
https://snag.gy/gV37yC.jpg
https://snag.gy/KbXm23.jpg
Where do I place the debugger? Put in a few different places but not showing.
Thanks Healyhatman.
In your users table (and any save data actions) get rid of created, user_id, and modified. Created and Modified aren't in the core table, and user_id should be just id and you shouldn't be inserting or changing it anyway. In this example, I'm talking about your second picture.
For the last picture, are you sure they're not just the autofill values your browser is entering in?
Your users table should ONLY have the following fields.
id, name, username, email, password, block, sendEmail, registerDate, lastvisitDate, activation, params, lastResetTime, resetCount, optKey, otep, requireReset
Anything else shouldn't be there.
And the debugger goes after all the other actions, but if you have a redirect you won't see it.
OK so all that goes into the overrides and updates are like in the snaggy below
https://snag.gy/Fdqr5n.jpg
Yes, the users table has only the fields you mention. But the edit profile form will allow user to change name and email, and some fields from the related table.
Is the setup in my 12.37 post good?
No, I'm wrong. Moons ago I did add fields to the users table and I cant remove them now, otherwise I get redirected to the front end and cant login to backend
That doesn't make any sense, don't know what you've done then.
Have deleted all custom fields in the fields table and deleted all non-core fields in the users table.
Now both the forms (registration and the update form) throw error.
Wonder if this is linked to the new action save custom user, where I did set up some custom fields previously but none now. And cannot delete the values.
https://snag.gy/HngPzt.jpg
https://snag.gy/z8VQsq.jpg
Did you remember to clear the Chronoforms cache ? And turn off "auto manage data table" ?
Got it working now. Edit the name and email (users table) immediately reflects in the directory.
But in order to see the change in the update form, have to log out and back in. Then the update form reflects the change. So seems when the update form is opened it is not querying the db, it needs a requery action or similar
Update form is now saving edited data to the two tables, ie users and the related table. Good.
Prob is that the user id is not passed to the related table. So each table has the correct values against the correct fields but there is no foreign key in the related table.
Adding a condition userid = {user:id} use doesn't help.
Thanks
https://snag.gy/QCnAjP.jpg
user_id or userid? And what's going on instead, is it 0? Because if it's 0 you're not logged in
Okay I see. If you look, you have some fields set to be used on insert and some on update. The insert ones obviously aren't going to work, because you're updating not inserting.
OK, now it's working.
Those three fields that are created by the system - except for user_id, which I have changed to userid - why are they given as default. Presume if I want to track when an edit was made I'll need to create those fields in the related table?
Thanks for the help Healyhatman
They're given by default for people that don't know what they're doing and just want to save everything into an automatically created database table.
OK, so that explains auto manage the data table
Doing fuller testing on the edit form, when first registering a user, the dropdown values are saved to the related table. But when calling the form for editing only the values that have been typed in the registration form, show. The dropdown values don't show. So they are in the table but dont show on the editing form. Is it because {data:} in the Data Provider selects typing only? How to solve? Thanks
If it's a drop down you use the value from the database as the "selected value" in the dropdown settings.
Sorry dont follow. Now in the design section ?
https://snag.gy/n8watA.jpg
Yes, in there. {var:read_data#.model.field}
Yes that works, thanks.
Wish there was documentation for all these settings ...
Now the submit button does not do anything and I have not changed any settings. Endless work Chrono, Have not touched another extension in weeks ...
Thanks for help Healyhatman
I assume you probably have a required field hidden but not validation-disabled.
Seems not. Have turned off all required fields.
Have been submitting forms today, no prob. Then this.
No error messgs
So you click submit and NOTHING happens?
if you remove the recaptcha?
The main registration form also prob error 1062 Duplicate entry '1074-2' for key 'PRIMARY'
Well that's an error with your save data action then you'd have to show me
Here's the save data settings for the main reg form.
When do u use Data Overrides v Data Provider ?
https://snag.gy/sfTQyo.jpg
You use data provider when the form field name matches the database field name (or the field name from the array you've passed matched, if that's not {data:} )
You use overrides when they don't match, or you want to ensure it has a specific value, or you want it to have a certain value if the form field isn't passed, or you want a value from a {var:} or whatever.
I use it because I want to make certain the value I want is put where I want it
Understand, thanks
Any idea from https://snag.gy/sfTQyo.jpg why form not submitting
Duplicate entry '1076-2' for key 'PRIMARY'
Then go to phpmyadmin and refresh page and the form data is submitted with key 1076. Before the form is submitted there is no 1076 in the users table.
https://snag.gy/fLmABR.jpg
Well you're inserting a new record right? And you're using the user id as the primary key? Can't have duplicate primary keys.
Not sure how to resolve, please help.
change auto to on duplicate key update and change all fields to insert and update
1: That looks fine, I doubt the error is from your Joomla User action
2. That looks fine too, but I assume that's where the error is. Is userid the primary key for that table?
3. For this one, you need to have at least a basic understanding of Joomla. This is an array of the groups you want the user to be in. If you look at your user groups, "2" is probably "Registered". If you wanted the user to say be in group 2 and 3, you would have {value:[2,3]} . That syntax should be either in the shortcodes FAQ or the shortcodes reference I give away on my site.
4. This is for if you want the user to have to provide an activation code, usually in a URL parameter, before they can log in. So if you put {uuid:} in there, it puts a code in the "activation" field in the #__users table. If you have a look at the New User Registration demo, they show you how to use that field. If you don't need them to verify their email address before logging in the first time, you can leave it blank.
Thanks for this Healyhatman, will save it.
You're correct re 2. Userid should be id. Sorry for wasting your time,..