Forums

is this the correct way to set up a Joomla a user with additional fields

hangbill 14 Jan, 2019

Hi

CF V6
Is this the correct way to set up a joomla user registration form for new users, with additional fields.
Not worrying about security, reloads, emails etc at this time. Just want high level understanding how to create the Joomla registration form with additional fields.

My form is not working.
So am trying to start with an understanding of how the form creation process works, high level, then try work towards fixing it.

Create a CF form that has text fields for name, username, password and email, plus the additional fields (eg confirm password, company, job title etc)
Do not use CF to create a table. Create Joomla user fields that mirror the CF fields (In Jooma admin menu-> Users / Fields)

In CF setup, under Submit
Create two actions, save user and save data

In Save User action provide the name, username, password and email details
Leave the other default values, {uuid:} and {value:[2]}. Not sure what they represent

In CF setup, under the Save Data action
Leave the default model name
For the database table, type #_fields_values (the hash at the beginning represents the Joomla table prefix)
For the data provider type {data:}
For write action leave as auto detect

Then in data override on insert do the following, for eg
created:{date:Y-m-d H:i:s}
user_id:{user:id}

field_id:{6}
item_id:{user:id}
value:{data:company}

field_id:{18}
item_id:{user:id}
value:{data:confirmpassword}

This needs some explanation
The first 2 lines are default, leave as is.
The additional groupings represent the extra fields that were added to the Jooma user fields were created

When the Joomla user fields were created each one was assigned an id. So in the field_id:{6} example, 6 represents the id of the company field.
Leave item_id:{user:id} as is.
The last line value:{data:company} references the field name.

Lastly, on the save data action box, disable auto manage the data table and disable auto save fields.






healyhatman 14 Jan, 2019
No that's not right.

For the Joomla User Action

Activation code provider: put something in here if you want the user to have to verify/activate their account first with a special code - the {uuid:} generates this code for you. You can then use it later with {var:joomla_user#.activation} when you're making a verification email.
Groups id provider: this is what user group you want the user added to. The default of {value:[2]} creates an array with one number in it - 2 - which is the group id for the "registered" group.

For your save data action
First of all you will need two, one for each field value you're trying to save.
Don't wrap the static values in curly brackets. "field_id:{6}" should be "field_id:6"
Get rid of created and user_id, they're not fields in the fields_values table.
Get rid of the "{data:}" in the data provider, this will try to match field names in your data and your table and overwrite those values.
hangbill 15 Jan, 2019
Thanks Healyhatman, knew I hadn't got it right. Good info, thanks.
So an additional 15 fields will require 15 data save actions?

I'll buy your demo form for 5 Smackaroos.
Do u delete my card details after the purchase? And presume can download it after buying?
healyhatman 15 Jan, 2019
I don't store your card details it goes through PayPal, and yes you can download it on my My Profile page.

Yes it will require 15 save data actions OR you can store the information in an array. So all the fields you have that you turn into fields_values entries, you could call them
fields[field_id]
replacing "field_id" with the ID of the field in your fields_values table. When submitted, they will be in an array called "fields". For example if you have 3 custom fields and their IDs are 1, 3, and 9, you call your 3 fields fields[1] , fields[3] , fields[9]. Then when the user submits, the data will look like this
    [fields] => Array
        (
            [1] => a
            [3] => b
            [9] => c
        )

SO now you put a loop event, data source {data:fields}
Put your save data action in that, with overrides set to
field_id:{var:loop_event#.key}
item_id:{user:id}
value:{var:loop_event#.row}
hangbill 16 Jan, 2019
Thanks Healyhatman
Didn't change Save User. Added custom code, a loop and edited Save Data.

Seems I've done something wrong ... . Not sure what error messg means because usermame / email did not previously exist







healyhatman 16 Jan, 2019
Loop event, not loop. And replace the # with the number of your loop_event
hangbill 16 Jan, 2019
Still getting duplicate name / email error. Is being generated form the Save User action. Looked in the #
_users table and I see that it has the exact text that is in the provider boxes in Save User. So name in the provider box is passing as a literal, not a variable. Tried {var:name} but that doesn't pass anything. Whereas {name} passes as literal.

Also in the #_fields_values table there are 2 "0" values in field_id. Not sure how they got there and cant delete because "selection does not contain a unique column"
























healyhatman 16 Jan, 2019
Use {data:fieldname} when you're getting it from form data
hangbill 16 Jan, 2019
Got it, thanks. Values now saving to users table.
But nothing going to _fields_values ... .
healyhatman 16 Jan, 2019
did you put the save data inside a loop event? And replace the#with the number?
hangbill 16 Jan, 2019
Yes, see image 4th from bottom.
?? also problem with #_fields_values table, bottom image
healyhatman 16 Jan, 2019
You forgot to fill in the data provider.
hangbill 16 Jan, 2019
Yes, have now got {data:fields} in both the loop event and save data event. Sill nothing passing to fields_values.
Username etc passing to users field but nothing to fields_values.
The bottom image in this post shows something amiss with the _fields_values table ?
healyhatman 16 Jan, 2019
Don't put anything in the save_data "data provider" field.

Can you copypaste the debug output please
hangbill 17 Jan, 2019
The debugger is not being triggered. After submit get blank screen.
User data is passed to the users table but nothing to _fields_values


, not sure why.
healyhatman 17 Jan, 2019
It's not being triggered because you have it in the fail option. Put it at the every bottom instead.
hangbill 17 Jan, 2019
Have removed value from Save Data / Data Provider
Debugger for Save User
Array
(
    [option] => com_chronoforms6
    [cont] => manager
    [chronoform] => memberregistrationnew
    [event] => submit
    [name] => Idona Duncan
    [username] => numilax
    [email] => city@mailinator.com
    [password] => Pa$$w0rd!
    [confirmpassword] => Pa$$w0rd!
    [ciuStatus] => 
    [title] => Vel dolore harum placeat explicabo Ut fuga Rem maxime et aliquam
    [occupation] => 
    [describeoccupation] => 
    [experience] => 
    [explainexperience] => 
    [company] => Barber Ochoa Associates
    [city] => Impedit placeat dolor minima aut laudantium vel sapiente eu fugiat consequatur laboriosam
    [province] => 
    [country] => Canada
    [nameCountry] => 
    [telephone] => +147-26-6163910
    [button66] => 
    [0d4e14f532d92632bd557daf62d88643] => 277ebc5fef7c7383c57c50dfb8f0b4e6
    [jSGCacheBypass] => 1
    [51022d510d7aa6cae53d0e57d83fa7a8] => 1
)
Array
(
    [joomla_user15] => Array
        (
            [_success] => User saved successfully under id 1083
            [var] => Array
                (
                    [name] => Idona Duncan
                    [username] => numilax
                    [email] => city@mailinator.com
                    [password] => Pa$$w0rd!
                    [block] => 1
                    [activation] => d5d47ab1-afb6-444a-a0c2-096986476bfc
                    [registerDate] => 2019-01-17 02:46:17
                    [id] => 1083
                )

        )

)
healyhatman 17 Jan, 2019
No no no. Just put a debugger at the very end, as the very last thing. Not inside a fail or success event.

Also if the user already exists, which it will if you haven't deleted the user you've created each time you submit the form, then it is going to fail because the user already exists.
hangbill 17 Jan, 2019
OK, debugger at bottom.
Same result.
Using form filler, random data, so users not duplicated. Values are being saved to users table.
Array with additional fields has been created, but not saving.
Still wonder about the 2 random values in the _fields_values table (field_id column), that I cant delete because there's no unique column (presume no PK) ??
The image of that table is above, colored the top purple. Wouldn't that table need a foreign key, to link it to the user






Array
(
    [option] => com_chronoforms6
    [cont] => manager
    [chronoform] => memberregistrationnew
    [event] => submit
    [name] => Nina Hahn
    [username] => rofyhoji
    [email] => taxe@mailinator.net
    [password] => Pa$$w0rd!
    [confirmpassword] => Pa$$w0rd!
    [ciuStatus] => 
    [title] => Ut minim aut et quae eveniet duis voluptas accusantium
    [occupation] => 
    [describeoccupation] => 
    [experience] => 
    [explainexperience] => 
    [company] => Pittman and Jimenez Traders
    [city] => Nam ducimus expedita maiores tempore ut
    [province] => 
    [country] => Canada
    [nameCountry] => 
    [telephone] => +128-73-7136445
    [button66] => 
    [0d4e14f532d92632bd557daf62d88643] => 277ebc5fef7c7383c57c50dfb8f0b4e6
    [jSGCacheBypass] => 1
    [51022d510d7aa6cae53d0e57d83fa7a8] => 1
)
Array
(
    [joomla_user15] => Array
        (
            [_success] => User saved successfully under id 1096
            [var] => Array
                (
                    [name] => Nina Hahn
                    [username] => rofyhoji
                    [email] => taxe@mailinator.net
                    [password] => Pa$$w0rd!
                    [block] => 1
                    [activation] => 9462bd4e-7a77-441f-b451-b505bef3b1b5
                    [registerDate] => 2019-01-17 03:16:41
                    [id] => 1096
                )

        )

)
healyhatman 17 Jan, 2019
Right so remember what I said about how you should name the fields? You haven't done that.

fields[fieldname]

To delete the rows in your database, make a delete data action or just use MYSQL in PHPMyAdmin
hangbill 17 Jan, 2019
OK, I'll go through your feedback and look for what I missed. Will pick it up tomorrow.
Thanks for staying with this Healyhatman...
Max_admin 17 Jan, 2019
Hi Bill,

I have a new action to store custom fields created using the Joomla fields manager, in that case you will only need to create the extra fields in Joomla and in your form you will need the "Joomla save user" action and the new "custom fields" action.

No need for a loop or an extra database table.

Best regards
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
hangbill 17 Jan, 2019
Ah, excellent Max.
Is the new action available in an update CF version?
Max_admin 17 Jan, 2019
No, please send me a message using the contact us page and I will send you the file, it should be added in the next official update!

Best regards
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
hangbill 17 Jan, 2019
Will do, thanks.
But have gone so far, and seem so close, to the loop solution that I want to get this right too. Will likely be useful in other situations that require loops / saves etc
cesarmtz 24 Jan, 2019
Hi there. Did you get this to work?
hangbill 24 Jan, 2019
No, not yet. However Max did help by providing a patch that links the user table to _fields_values. It works but has a problem in that the _fields_values table has been built vertically. And it's going to be a challenge to format the output as a table, ie column headings with values under each heading. So am trying a new approach, create 2 forms, the first captures the Joomka user data, and the second form captures the additional data. The 2nd form is based on a horizontal table, ie a field for each additional piece of data. Then join the 2 forms, which should be easier to build a table listing. Bit complicated but long story short I will pick this post up again but have to redirect at this time.
healyhatman 24 Jan, 2019
To read them all for a table view you would have to do it the way I said. For your purposes better to create that additional table and link it through either user id or some other foreign key. When reading you add 5he second table as an additional model in your data read.
hangbill 25 Jan, 2019
Yes, the design plan now is to try do the 2 forms in 1 step, ie submit and save the user form, then call the userid and open the 2nd form.
hangbill 11 Feb, 2019
Back on the job ... . Still need to solve.
Not sure if I should open a new post - this one is long and rambling.

To summarize, these are the requirements
  1. the site is a for a closed group, some 600 - 800 members
  2. need to register members as Joomla users, with additional fields (eg company, job title, occuption, experience etc)
  3. create a searchable directory of members (table format), so members can find one another. The directory will potentially include all of the submitted data, ie the Joomla User fields as well as the addtional fields
  4. create a form so that member can edit own registration details. For eg member might change company, job title etc. Only non-editable field is username, all other fields can be edited.
  5. The editing form must have the same functionality as the original submission form. For eg there are conditional form elements. If member changes a selection which in turn opens a different form element then the original value must be deleted from the database and the new one saved.
  6. Would like to build this functionality so that it's seamless from the member perspective, ie one form that submits to both the Users table as well to the new table that holds the additional fields.
ITadminguy 11 Feb, 2019
just use easyprofile component to first create your fields which automatically gets created in their jsn_user table

then put any of those fields in your chronoform

the one main difference is that cf uses = for saving arrays like radio and checkboxes while easyprofile has to save as | when you create the same in easyprofile

then save to db jsn_users On Submit

or you can save individual fields one by one in a custom code On Submit

hangbill 12 Feb, 2019
Thanks.
What is the component name - I don't see an extension called easyprofile
healyhatman 12 Feb, 2019
There's no need to do that, just create the database table yourself it's not that hard
hangbill 12 Feb, 2019
Yes I have made the table. It has a primary key and and key to link to the Users table. But how do I create the query that links the two so that it operates like one table
healyhatman 12 Feb, 2019
I'm sure we went through this. In your read data add a second model, related it to the first model, put the relation conditions to
model1.userfield:model2.field2
Where the models and fields are whatever they're supposed to be
hangbill 12 Feb, 2019
Yes you prob did explain it. I'm getting so mixed up with this thing. Main thing trying to achieve is one shot solution from member perspective => one form, one submission, saved form data then available for editing by member. And of course all the additional field data sitting in its own table, not in the Users table.
Will check it out more this evening, thanks.
hangbill 16 Feb, 2019
OK, I've got the form submitting to two tables, the users table and a custom table I created. So have placed Save Data table inside the Save User and it works. Name, Username, Password and Email goes to the users table and the values of 15 other fields go to the misc_user_addfields table.

So here's the prob as far as I see it. The administrator gets a notification that a new user has registered. The admin has to approve the registration. So he goes to the Manage Users section in Joomla and can see the new registration. But the admin also needs the data that was submitted to the misc_user_addfields table in order to know whether to approve the registration. How does he know which record in misc_user_addfields relates to the relevant registration record in the users table.

The users table has an auto increment primary key, id. The misc_user_addfields table also has an id primary key, as well as a userid field that I can use as the foreign key for the users table. But as the form is submitted how does the key in the users table get added to the foreign key in misc_user_addfields so that the two tables are linked.

healyhatman 16 Feb, 2019
{var:joomla_user#.id}

And if you want to show all that you might have to make a CCv6 connection and you can have all the fields displayed and a button to enable the user.
hangbill 17 Feb, 2019
So here's a weird thing – wonder if it’ll work.

In the misc_user_addfields table, in addition to other fields, have also included fields name, username, email and password (same as in the users table) .
As mentioned in previous post the form has two save actions, Saver User and Save Data. Save User saves name, username, email and password to the users table. In
the Save Data section have set Data Provider to {data:}. Seems therefore that name, username, email and password are also saved to the misc_user_addfields
table. So although the 2 tables are not linked I am sending all the data from the form submission to the misc_user_addfields table. So if I create a listing
of this table then the Joomla admin will have sufficient info to figure whether to approve the registration or not.
So what I have is a users table that has not been altered in any way, this is good. And a custom table that contains the additional registration data that I need to collect as well as a copy of the name / username / email / password values that are in the users table

And presume can also use Chronoform Connectivity in a similar fashion, to create a form where a user can edit their registration details. In other words if members edits name / password / email then the changes are sent to both the users table as well as to misc_user_addfields, whereas any edit made to the fields that are not in the users table are sent only to misc_user_addfields . Will likely make username unique and not editable.
Prob not explaining myself properly but am thinking that this might be a way to go ??

This is the debug info



Array
(
    [chronoform] => memberregistrationnew
    [event] => submit
    [name] => Jada Slater
    [username] => wecodawesa
    [email] => qikujafo@mailinator.net
    [password] => Pa$$w0rd!
    [confirmpassword] => Pa$$w0rd!
    [usernamefk] => 
    [ciuStatus] => 
    [title] => Culpa cillum minus n
    [occupation] => 
    [describeoccupation] => 
    [experience] => 
    [explainexperience] => 
    [company] => Burns Villarreal Associates
    [city] => Et pariatur Pariatu
    [province] => 
    [country] => Canada
    [nameCountry] => 
    [telephone] => +1 (263) 905-2918
    [button66] => 
    [phpbb3_bbxl1_u] => 1
    [phpbb3_bbxl1_k] => 
    [phpbb3_bbxl1_sid] => 23045c448862f7a9264430a190eac754
    [0d4e14f532d92632bd557daf62d88643] => 87e0c0a54c683449b6cc2c3e4a67519c
    [c42234b300a2feaffea15712e4c1305d] => a29738a491d9b76fe217fb84d26cf63a
    [joomla_user_state] => logged_in
    [jSGCacheBypass] => 1
    [Itemid] => 1937
    [option] => com_chronoforms6
    [view] => form
    [7f479ba2ad89d6f65e1b3cc9e6495d8f] => 1
)
Array
(
    [joomla_user15] => Array
        (
            [_success] => User saved successfully under id 1167
            [var] => Array
                (
                    [name] => Jada Slater
                    [username] => wecodawesa
                    [email] => qikujafo@mailinator.net
                    [password] => Pa$$w0rd!
                    [block] => 1
                    [activation] => d386bee5-70bf-4001-9418-840970f6770e
                    [registerDate] => 2019-02-17 16:04:20
                    [id] => 1167
                )

        )

    [save_data17] => Array
        (
            [data] => Array
                (
                    [chronoform] => memberregistrationnew
                    [event] => submit
                    [name] => Jada Slater
                    [username] => wecodawesa
                    [email] => qikujafo@mailinator.net
                    [password] => Pa$$w0rd!
                    [confirmpassword] => Pa$$w0rd!
                    [usernamefk] => 
                    [ciuStatus] => 
                    [title] => Culpa cillum minus n
                    [occupation] => 
                    [describeoccupation] => 
                    [experience] => 
                    [explainexperience] => 
                    [company] => Burns Villarreal Associates
                    [city] => Et pariatur Pariatu
                    [province] => 
                    [country] => Canada
                    [nameCountry] => 
                    [telephone] => +1 (263) 905-2918
                    [button66] => 
                    [phpbb3_bbxl1_u] => 1
                    [phpbb3_bbxl1_k] => 
                    [phpbb3_bbxl1_sid] => 23045c448862f7a9264430a190eac754
                    [0d4e14f532d92632bd557daf62d88643] => 87e0c0a54c683449b6cc2c3e4a67519c
                    [c42234b300a2feaffea15712e4c1305d] => a29738a491d9b76fe217fb84d26cf63a
                    [joomla_user_state] => logged_in
                    [jSGCacheBypass] => 1
                    [Itemid] => 1937
                    [option] => com_chronoforms6
                    [view] => form
                    [7f479ba2ad89d6f65e1b3cc9e6495d8f] => 1
                )

            [_success] => Data saved successfully
            [log] => Array
                (
                    [0] => INSERT INTO `misc_user_addfields` (`name`, `username`, `email`, `password`, `confirmpassword`, `usernamefk`, `title`, `occupation`, `describeoccupation`, `experience`, `explainexperience`, `company`, `city`, `province`, `country`, `telephone`)  values  ('Jada Slater', 'wecodawesa', 'qikujafo@mailinator.net', 'Pa$$w0rd!', 'Pa$$w0rd!', '', 'Culpa cillum minus n', '', '', '', '', 'Burns Villarreal Associates', 'Et pariatur Pariatu', '', 'Canada', '+1 (263) 905-2918');
                )

            [var] => Array
                (
                    [name] => Jada Slater
                    [username] => wecodawesa
                    [email] => qikujafo@mailinator.net
                    [password] => Pa$$w0rd!
                    [confirmpassword] => Pa$$w0rd!
                    [usernamefk] => 
                    [title] => Culpa cillum minus n
                    [occupation] => 
                    [describeoccupation] => 
                    [experience] => 
                    [explainexperience] => 
                    [company] => Burns Villarreal Associates
                    [city] => Et pariatur Pariatu
                    [province] => 
                    [country] => Canada
                    [telephone] => +1 (263) 905-2918
                    [id] => 12
                )

        )

)
healyhatman 17 Feb, 2019
instead of using {data:} the provider should be empty, it should NOT be set to auto manage or auto save, you should manually create your table fields, and manually put the data you want to save in the override on insert . You should NOT save data to the table that is already in the user's table, except for the new user id which you get with the syntax I gave you.

Then in CC you would bring up the user's by date created descending, and your read data will have a second model getting data from the other table where the user id matches.

Again: should not be storing duplicate data in multiple tables.
hangbill 17 Feb, 2019
Yes I know I shouldnt duplicate, from db design, but I've struggled so with this form builder... . OK back to drawing board. Thanks
healyhatman 17 Feb, 2019
Don't need to go back to the drawing board, I already told you what you need to do.
hangbill 17 Feb, 2019
is the format for override on insert like this company:{data:} ?
so company is the field and it gets the value from the form submission - looks like this format in the V6 manual
healyhatman 17 Feb, 2019
databasefield:{data:formfield}
hangbill 17 Feb, 2019
OK got data saving to correct tables.
Now need to do the link. Not talking about reading linked tables, seems first need to get the user id into the misc_user_addfields table, as a foreign key.
Cant upload pics, prob hit my limit ...
healyhatman 17 Feb, 2019
Told you that already too.
user_id:{var:joomla_user#.id}
Replace user_id with the name of your foreign key in the database, replace the # with the number of your Save User action.
hangbill 18 Feb, 2019
Close now.
The table misc_user_addfields has a field called userid (int11).
The Save User action is called joomla_user15

userid:{var:joomla_user15.id}
ciustatus:{data:ciustatus}
title:{data:title}
occupation:{data:occupation}
describeoccupation:{data:describeoccupation}
experience:{data:experience}
telephone:{data:telephone}
city:{data:city}
province:{data:province}
country:{data:country}
namecountry:{data:namecountry}

This is the debugger. The userid 1190 is correct, but not inserting it into misc_user_addfields
Array
(
[joomla_user15] => Array
(
[_success] => User saved successfully under id 1190
[var] => Array
(
[name] => Graiden Dixon
[username] => fysime
[email] => dutugyq@mailinator.net
[password] => Pa$$w0rd!
[block] => 1
[activation] => 3b72dac1-7959-49bf-9e11-308b2726eb0a
[registerDate] => 2019-02-18 00:27:44
[id] => 1190
)

)

[save_data17] => Array
(
[data] => Array
(
[userid] => 1190
[ciustatus] =>
[title] => Laudantium ut tempo
[occupation] =>
[describeoccupation] =>
[experience] =>
[telephone] => +1 (419) 183-5166
[city] => Reprehenderit paria
[province] =>
[country] => Canada
[namecountry] => Flynn Beach
)

[_success] => Data saved successfully
[log] => Array
(
[0] => INSERT INTO `misc_user_addfields` (`ciustatus`, `title`, `occupation`, `describeoccupation`, `experience`, `telephone`, `city`, `province`, `country`, `namecountry`) values ('', 'Laudantium ut tempo', '', '', '', '+1 (419) 183-5166', 'Reprehenderit paria', '', 'Canada', 'Flynn Beach');
)
hangbill 18 Feb, 2019
GOT IT !!!
Thanks so very much healyhatman ... would have given up without your help ... .
Now going to summarize and document, for go forward.
Sent a few buckeroos ... thanks
healyhatman 18 Feb, 2019
Thanks mate. Glad to know you got it sorted.
This topic is locked and no more replies can be posted.