Am using Chronoforms5 to add data to the Joomla users table.
Now want to edit a record in that table, using a form. So I need to fill the form with the user data of the logged-in user. The form is a copy of the form used to initially submit the data. Have read and tried so many things, nil works.
So in general outline I have placed a DB Read action on the OnLoad event of the form, before the render action. Have set the table name as jospc_users. Have set Enable Model ID to no. Ddon’t understand what Model ID does - have have read it is mainly used when joining multiple tables. Have left the Model ID title as given by the system.
Then in the Conditions box, have tried numerous syntaxes, most recently
The thing is I don’t really understand what I’m doing here. For eg what is the difference between $form->data… and return array(…), and when to use each. In any event the debug is showing data being returned, but form not filled.
Another issue is that the debug array shows my id, but I have logged in as another registered user and am expecting the form to be filled with values of the other user.
Can anyone help please.
Data Array
Debug Info
Now want to edit a record in that table, using a form. So I need to fill the form with the user data of the logged-in user. The form is a copy of the form used to initially submit the data. Have read and tried so many things, nil works.
So in general outline I have placed a DB Read action on the OnLoad event of the form, before the render action. Have set the table name as jospc_users. Have set Enable Model ID to no. Ddon’t understand what Model ID does - have have read it is mainly used when joining multiple tables. Have left the Model ID title as given by the system.
Then in the Conditions box, have tried numerous syntaxes, most recently
<?php
$juser = \JFactory::getUser();
//$form->data['id'] = $juser -> id;
return array("id" => $juser);
?>
The thing is I don’t really understand what I’m doing here. For eg what is the difference between $form->data… and return array(…), and when to use each. In any event the debug is showing data being returned, but form not filled.
Another issue is that the debug array shows my id, but I have logged in as another registered user and am expecting the form to be filled with values of the other user.
Can anyone help please.
Data Array
Array
(
[c3598951ba4603eaeeeef619099aa286] => 1
[id] => 919
[name] => Administrator
[username] => hangbill
[email] => admin@ublizi.com
[password] => $2y$10$tVsqcrA3pZrXnJG.YDoWeuHH3YgBe6nblDraXW8H8lac.2pYVM9wO
[occupation] =>
[describeoccupation] =>
[ciuStatus] =>
[experience] =>
[explainexperience] =>
[company] =>
[block] => 0
[sendEmail] => 1
[registerDate] => 2016-10-31 20:27:08
[lastvisitDate] => 2017-01-27 13:37:56
[activation] => 0
[params] => {"admin_style":"","admin_language":"","language":"","editor":"","helpsite":"","timezone":""}
[lastResetTime] => 0000-00-00 00:00:00
[resetCount] => 0
[otpKey] =>
[otep] =>
[requireReset] => 0
)
Debug Info
Array
(
[18] => Array
(
[DB Read] => Array
(
[Queries] => Array
(
[0] => SELECT `Data18`.`id` AS `Data18.id`, `Data18`.`name` AS `Data18.name`, `Data18`.`username` AS `Data18.username`, `Data18`.`email` AS `Data18.email`, `Data18`.`password` AS `Data18.password`, `Data18`.`occupation` AS `Data18.occupation`, `Data18`.`describeoccupation` AS `Data18.describeoccupation`, `Data18`.`ciuStatus` AS `Data18.ciuStatus`, `Data18`.`experience` AS `Data18.experience`, `Data18`.`explainexperience` AS `Data18.explainexperience`, `Data18`.`company` AS `Data18.company`, `Data18`.`block` AS `Data18.block`, `Data18`.`sendEmail` AS `Data18.sendEmail`, `Data18`.`registerDate` AS `Data18.registerDate`, `Data18`.`lastvisitDate` AS `Data18.lastvisitDate`, `Data18`.`activation` AS `Data18.activation`, `Data18`.`params` AS `Data18.params`, `Data18`.`lastResetTime` AS `Data18.lastResetTime`, `Data18`.`resetCount` AS `Data18.resetCount`, `Data18`.`otpKey` AS `Data18.otpKey`, `Data18`.`otep` AS `Data18.otep`, `Data18`.`requireReset` AS `Data18.requireReset` FROM `jospc_users` AS `Data18`
)
)
)
)
Hello hangbill,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How to load record data from a database table into your form
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How to load record data from a database table into your form
P.S: I'm just an automated service😉
Thanks AI. I have seen that article, and others.
It says I should place the following code in the Conditions box of DB Read
I have done this, but am not sure what the request_param-name is. Maybe got other things wrong too - the code below returns "id" IS NULL.
It says I should place the following code in the Conditions box of DB Read
<?php
return array("db_field_name" => $form->data("request_param_name"));
?>
I have done this, but am not sure what the request_param-name is. Maybe got other things wrong too - the code below returns "id" IS NULL.
<?php
$juser = \JFactory::getUser();
return array("id" => $form->data("$juser ->id"));
?>
Hi hangbill,
The code should be like this:
And the "request_param_name" is something you pass to the form in the url, so you may have fform_link¶m=xxx
Best regards,
Max
The code should be like this:
<?php
$juser = \JFactory::getUser();
return array("id" => $juser->get("id"));
?>
And the "request_param_name" is something you pass to the form in the url, so you may have fform_link¶m=xxx
Best regards,
Max
Thanks Max
I logged in as user id 928. It now returns the corrects data, see the debugger, but does not pass the id to the form. The form opens but no data in it.
I logged in as user id 928. It now returns the corrects data, see the debugger, but does not pass the id to the form. The form opens but no data in it.
Array
(
[18] => Array
(
[DB Read] => Array
(
[Queries] => Array
(
[0] => SELECT `Data18`.`id` AS `Data18.id`, `Data18`.`name` AS `Data18.name`, `Data18`.`username` AS `Data18.username`, `Data18`.`email` AS `Data18.email`, `Data18`.`password` AS `Data18.password`, `Data18`.`occupation` AS `Data18.occupation`, `Data18`.`describeoccupation` AS `Data18.describeoccupation`, `Data18`.`ciuStatus` AS `Data18.ciuStatus`, `Data18`.`experience` AS `Data18.experience`, `Data18`.`explainexperience` AS `Data18.explainexperience`, `Data18`.`company` AS `Data18.company`, `Data18`.`block` AS `Data18.block`, `Data18`.`sendEmail` AS `Data18.sendEmail`, `Data18`.`registerDate` AS `Data18.registerDate`, `Data18`.`lastvisitDate` AS `Data18.lastvisitDate`, `Data18`.`activation` AS `Data18.activation`, `Data18`.`params` AS `Data18.params`, `Data18`.`lastResetTime` AS `Data18.lastResetTime`, `Data18`.`resetCount` AS `Data18.resetCount`, `Data18`.`otpKey` AS `Data18.otpKey`, `Data18`.`otep` AS `Data18.otep`, `Data18`.`requireReset` AS `Data18.requireReset` FROM `jospc_users` AS `Data18` WHERE `Data18`.`id` = '928'
)
)
)
)
Hi hangbill,
The db read is above the "html" action ? the mode id is enabled or disabled ?
Best regards,
Max
The db read is above the "html" action ? the mode id is enabled or disabled ?
Best regards,
Max
yes the db read is above the html action and model id is disabled. will try it enabled now and see what happens
If the model is disabled then your form fields names should match the table fields names, but if its enabled then the form fields should be like this:
Best regards,
Max
Model[field]
Best regards,
Max
Dont understand the model id but in any event it is disabled. Tried it enabled too, does not work but data array still accurate as per debugger
The form fields names match the table fields names ?
I wonder if that's it. I made a copy of a form that I use with Connectivity and the field names have the table name appended to it, eg users[id]. I will remove the table name and test.
Nope that didn't channge anything.
Should the field names in the form layout be table[field] ?
Either way the loggedin user's record is not passing to the form, although the debugger does show all the user's values.
Should the field names in the form layout be table[field] ?
Either way the loggedin user's record is not passing to the form, although the debugger does show all the user's values.
Hi hangbill,
if the "Model id" is enabled in the "db read" then the form fields name should have the model name, but if its disabled then the fields names should be just the table fields names.
Best regards,
Max
if the "Model id" is enabled in the "db read" then the form fields name should have the model name, but if its disabled then the fields names should be just the table fields names.
Best regards,
Max
OK I now understand the link between model id status and field names, and the form now opens with the correct record. Very nice, thanks for your help Max.
I find it a challenge understanding some of the concepts, information in many different places. What are the min requirements for really getting a handle on Chronoforms, eg PHP, jQuewry, CSS etc? Will the Chronoform Book help or is that too out of date?
I find it a challenge understanding some of the concepts, information in many different places. What are the min requirements for really getting a handle on Chronoforms, eg PHP, jQuewry, CSS etc? Will the Chronoform Book help or is that too out of date?
Hi hangbill,
No problems!!
You usually do not need any technical knowledge to get what you want done in Chronoforms, just be familiar with the interface and the functions, but having knowledge of php, jQuery/css is a plus.
Another note, for managing database data, I suggest that you check the new ChronoConnectivity v6, 1st tutorial is here:
http://www.chronoengine.com/faqs/73-chronoconnectivity-v6/5283-build-a-basic-listing.html
You can manage data and build the forms in one place, but you must have php 5.6 (5.5 may work too I think).
Best regards,
Max
No problems!!
You usually do not need any technical knowledge to get what you want done in Chronoforms, just be familiar with the interface and the functions, but having knowledge of php, jQuery/css is a plus.
Another note, for managing database data, I suggest that you check the new ChronoConnectivity v6, 1st tutorial is here:
http://www.chronoengine.com/faqs/73-chronoconnectivity-v6/5283-build-a-basic-listing.html
You can manage data and build the forms in one place, but you must have php 5.6 (5.5 may work too I think).
Best regards,
Max
This topic is locked and no more replies can be posted.