Search user and load data with chronoconnectivity

AlessandroMagnoII 21 Aug, 2013
Hi,
I have used chronoform for make a form registration. This form save many data in a specific table. It work correctly.

In my siteweb one user is "admin" but he must work from frontend. I have this necessity:
1) The admin user should be able to search one user by username,
2) the user's should be load in a form,
3) the admin should be able to edit the data;

Can I do this? Can I load many data of one user into a form, after a search by username? Have many suggestions?

Thanks,

Alessandro
GreyHead 21 Aug, 2013
Hi Alessandro,

The simplest way is probably a two-page form. On page one have as drop-down (or a search box if you prefer) to select a user name. Then the second page can use a DB Record Loader to get the information for that user and load it into the form for editing.

Bob
AlessandroMagnoII 22 Aug, 2013
I understand. I should make a form with two pages. The DB Record Loader should read the cf_id from the first page, correct?
I'll try to do this method. I have a question, there is a FAQ where is explained how to load the username list on the "option" of the dropdown attribute in the form?

Thanks Bob.

Alessandro
GreyHead 22 Aug, 2013
HI Alessandro,

Please see this FAQ which may help. You can use the DB Multi Record Loader action to read the #__users table to get a list of usernames and ids.

There also used to be a Joomla! JHTML method to automatically create a drop-down user list. If you check the Joomla! documents that may still exist and you could add it using a Custom Element element in the form.

Bob
AlessandroMagnoII 22 Aug, 2013
Hi Bob,
I read the FAQ and now in the first page I can select one user from dropdown user list. I have another little question...when I select the user I have his username on the field "username_search", with the following code written on event "Custom Code" collocated "On subtim" I obtaing the corrispondig ID:
<?php 
   $username=$form->data['username_search']
   $user=JFactory::getUser($username)
   $user_id=$user->id
?>

How can I write this user_id in a text label on the second page of the form?
In this way I can read the user id from this "Label Text" and load with the "DB Record Loader" users's information.

I have read the tutorial for load data into the form from database table but don't work. How I should use the DB Record loader in my case?

Thanks a lot,

Alessandro
AlessandroMagnoII 23 Aug, 2013
Hi,
I try to explain better my problem.
In the first page I have a "Dropdown" element for search one user from a list of all registered user. This list is build with the action "DB Multi Record loader". The field name of Dropdown element is "user_search". The "DB Multi Record loader" load data from the table "mgtka_user".

In the second page there is a form (the same for user registration) and I should load the Table record from the field "user_search" using the "DB Record Loader". "user_search" should be my query for a search into a table "mgtka_chronoforms_data_Registrazione2" (this is the table for save the user data during the registering procedure).

I have read the FAQ for load on row data table into a form, but I don't undertand how to use the URL. I don't understand if I should use the same procedure reported in that FAQ.

At the moment I stop on the second page of the form becouse I can't find a tutorial or FAQ for load one row of one table from the username data (username is the name of fiel saved in the table during registering procedure). I think I shouldn't use the ID of user but the only username for load the row table data.

Have many suggestions?

Thanks,

Alessandro
GreyHead 23 Aug, 2013
Hi Alessandro,

Are you using ChronoConnectivity? This all sounds like a ChronoForms question?

I would create the first drop-down with the user id as the value of the option and the username as the text. Then you will have the User ID when the form is submitted.

I'm not clear how you have linked the pages of your form together. The User ID will be in the $form->data array after the first form submits.

Bob
AlessandroMagnoII 23 Aug, 2013
Hi Bob,
I use only chronoforms becouse, after your first post, I had supposed ChronoForms able to do what I need alone.

Yes in the first page I can load id and username in only one array. On the second page I use DB Record Loader for load the only row with the "username" choose on the dropdown on the first page. I'm not able to connect the two page. The DB Record Loader ask me the request parametres present in the URL but I can't set the URL page.

Am I on the wrong street? Have I understand wrong all post?

Sorry for my continuos questions, but I'm not able to respond alone...

Thanks,

Alessandro
AlessandroMagnoII 23 Aug, 2013
Hi,
this is my question: How can I use the DB Record Loader using another data than the request param in the URL?
these are images of my events and the current DB Record Loader:
[attachment=1]1.png[/attachment]
[attachment=0]2.png[/attachment]

Thanks,

Alessandro
GreyHead 23 Aug, 2013
Hi Alessandro,

You can use it with anything that is in the $form->data array. That would include data from a form submit immediately before this event; data from the current URL; data from a Session to Data action in this event; and any other data that you have added to the array with another action.

Bob
AlessandroMagnoII 24 Aug, 2013
Hi Bob,
thanks very much for your replies but maybe I lose some passaggi. My form doesn't work.
First page - with "DB Multi Record Loader" I create a dropdown list of registered users, the name of the dropdown filed is "username_search"; the datas are loaded from the table "mjtka_user" under ModelID "UserList", I've specified the fields: id,name,username...if I've understand correctly on this way load all id, name and username from the table "mjtka_user". These are the insert value on the "DB Multi Record Loader":
DB Field: empty
Table: "mjtka_user"
Request param: empty
Model ID: ListUser
Fields: id,name,username
This page work correctly. One click of the subtim button open the Second page.

Second page - here I use (after the action "MultiPage", before the "show html") the "DB Record Loader". The table where I search data is "mgtka_chronoforms_data_Registrazione2". I use the username how query for search. This is the inser value on "DB Record Loader"
DB Field: username
Table: "mgtka_chronoforms_data_Registrazione2"
Request param: 'username'
Model ID: empty
Load Under Model ID: No

I use request param: 'username' because on the first page I loaded the fields: id, name, username.

I can't understand where is my errors...when I click on the subtim button of the first page I display the form empty...can you help me to find these errors?

Thanks very much,

Alessandro
GreyHead 24 Aug, 2013
Hi Alessandro,

Getting the user data on the first page of your form is not useful unless you do something with it :-(

I suggest that you use it to populate a select drop-down of usernames (or 'names', if you prefer) so that you select a user before clicking submit.

Bob
AlessandroMagnoII 24 Aug, 2013
Hi Bob,
yes I just select the user before pressing the subtim button. I'm not able to find the error...

Alessandro
GreyHead 24 Aug, 2013
Hi Alessandro,

A can't debug your form for you.

I suggest that you add a Debugger action to the second form and see what query is being created.

Bob
AlessandroMagnoII 25 Aug, 2013
Hi Bob,
finally I found the problems. One was in the "Value" fields of the Dropdown, I had insert "id" then only id were saved in the array.
The second were the " ' " insert on Request Param. I erase the " ' " and now work.

Another question. When I click on subtim of the second page I save the edited data of the form. The data is save in the array and when I search another user are present the previous data in the array. How can I clean the array data before loading the form?

Thanks,

Alessandro
GreyHead 25 Aug, 2013
Hi Alessandro,

If you add a Session to Data action at the end of the On Submit event it has an option to clear the saved data.

Bob
This topic is locked and no more replies can be posted.