Forums

Show field in textbox

RobP 03 Sep, 2013
I try to fill a form with data from a table.

In the Events I have a custom code with:
<?php
$user =& JFactory::getUser();
?>
And a DBRecord loader that loads the user table.
In the Where section I have 'username' = ".$user."

I would like to show the field values for the logged in user in a Textboxes, is that possible?

Rob
GreyHead 03 Sep, 2013
Hi Rob,

Please see this FAQ

Bob

PS the syntax of your WHERE statement is broken: column names need to be in back-ticks `` not straight quotes; $user is an Object not a value there - you need $user->username; and any $ parameters need to be used inside <?php ?> tags. So this might work:
<?php
$user =& JFactory::getUser();
echo " `username` = '{$user->username}' ";
?>
but you probably don't need it . . .
RobP 04 Sep, 2013
Thanks Bob, it works now.

I missed that token is called Request Param in the DB Record Loader, makes sense now that I know it.

I'm trying to convert an old Delphi 2.0 survey program for workplace ergonomics to a web based program.

My programming experience is mostly with Pascal, started with Fortran (on punch cards) and Clipper. After reading some books I have a (very) basic understanding of PHP.


Rob
GreyHead 04 Sep, 2013
Hi Rob,

started with Fortran (on punch cards)


:-) Ah, yes, nothing like dropping the box of cards to pass a quiet hour or two.

Bob
RobP 04 Sep, 2013
Yes that was always a good one.

Loading a couple of boxes and having one of the last being shredded by the machine was also very funny. It was a good thing the reader was next to the (very noisy ) line printer

Rob
RobP 04 Sep, 2013
Is it possible to do the same with a Multi record loader, I would like to use several joint multi record loaders

In the debug the data array is:

Array
(
[option] => com_chronoforms
[chronoform] => x
[username] => admin
[test] => Array
(
[0] => Array
(
[id] => 514
[name] => Super User
[username] => admin
--- more fields ----
)

)

)

I don't know how to link the username to a text box.

Rob
GreyHead 05 Sep, 2013
Hi RobP,

While it is possible to link several DB Multi Record Loaders (see this FAQ) it's often simpler just to hand code the MySQL query in a Custom Code action and add the resulting array to the $form->data array along with the other form data.

I'm not sure I understand the question about linking a user name to a text box when the data is from a DB Multi-Record Loader?

If it from a DB Record Loader then usually it would be enough to give the textbox the name username.

Bob
RobP 07 Sep, 2013
I have a chronoconectivity connection with a couple of linked tables, and a chronoform for editing, the data that works great.

I also want to make something that allows users to edit their own data, if possible with the same connection and form (or a slightly modified version).

For the moment I don't know the right approach.

Rob
GreyHead 08 Sep, 2013
Hi Rob,

I'm a long way from expert in the current version of ChronoForms but I think that you can set Edit Permissions to Owner or Owner and admin. Does that do what you need?

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