Hi,
in a form, available only for registered users, so that the user data are already known, I want to to show the respective fields already filled with user-id and user-email - but still writable.
So, I used in "Setup" section a custom code:
$user =& JFactory::getUser();
if ( $user->id > 0 ) {
$form->data['user_name'] = $user->name;
$form->data['user_email'] = $user->email;
}
In the "Designer" section I tried to make these data visible by "Edit element settings" -> tab "General" - > field "Field value".
But no manner of writing the variable makes the data visible when loading the form.
In this article I found a possible solution, but this seems to require a custom code field in the "Edit element settings":
http://www.chronoengine.com/faqs/3119-how-can-i-ask-new-users-for-information-and-not-ask-logged-in-users
Where should I put that html code, if this would be the only solution?
But I think there must be some easier and more elgant way to prefill those two fields?!
Regards,
Herbert
in a form, available only for registered users, so that the user data are already known, I want to to show the respective fields already filled with user-id and user-email - but still writable.
So, I used in "Setup" section a custom code:
$user =& JFactory::getUser();
if ( $user->id > 0 ) {
$form->data['user_name'] = $user->name;
$form->data['user_email'] = $user->email;
}
In the "Designer" section I tried to make these data visible by "Edit element settings" -> tab "General" - > field "Field value".
But no manner of writing the variable makes the data visible when loading the form.
In this article I found a possible solution, but this seems to require a custom code field in the "Edit element settings":
http://www.chronoengine.com/faqs/3119-how-can-i-ask-new-users-for-information-and-not-ask-logged-in-users
Where should I put that html code, if this would be the only solution?
But I think there must be some easier and more elgant way to prefill those two fields?!
Regards,
Herbert
Hi Herbert,
It's quite easy, create your form, assuming your two fields "user_name" and "user_email" and a submit button, then in Events, before the HTML action set a custom action and insert your code. Please, see that your code is not html is a php code, so it need tags
And this should work,
BN
It's quite easy, create your form, assuming your two fields "user_name" and "user_email" and a submit button, then in Events, before the HTML action set a custom action and insert your code. Please, see that your code is not html is a php code, so it need tags
<?php $user =& JFactory::getUser();
if ( $user->id > 0 ) {
$form->data['user_name'] = $user->name;
$form->data['user_email'] = $user->email;
}?>
And this should work,
BN
Thanks BNDragon,
but you describe exactly what I did – including php tags of course – but the fields remain empty.
So that's why I thought that I have to pass over this information anywhere else.
Regards,
Herbert
but you describe exactly what I did – including php tags of course – but the fields remain empty.
So that's why I thought that I have to pass over this information anywhere else.
Regards,
Herbert
Hi Herbert,
Can you post some prints?
Or PM the link to backend form link and give me an access token to take a look?
BN
Can you post some prints?
Or PM the link to backend form link and give me an access token to take a look?
BN
Sorry, but I have it still on localhost workaround – unpublished yet in www.
I come back later when I have uploaded the site. Thanks anyway!
Herbert
I come back later when I have uploaded the site. Thanks anyway!
Herbert
Hi Herbert,
Just post some prints, it could help me understand your problem.
BN
Just post some prints, it could help me understand your problem.
BN
Hi Herbert,
To make them show up and be editable you need to add form Text Box elements in the Designer tab with the names user_name and user_email as well as the Custom Code.
Bob
To make them show up and be editable you need to add form Text Box elements in the Designer tab with the names user_name and user_email as well as the Custom Code.
Bob
Hi Bob,
I did all that, as I wrote in my original post - but what do you mean with "custom code" in designer section?
I got the user-data with custom code element already in On Load event. I don't understand you.
Regards,
Frank
I did all that, as I wrote in my original post - but what do you mean with "custom code" in designer section?
I got the user-data with custom code element already in On Load event. I don't understand you.
Regards,
Frank
This topic is locked and no more replies can be posted.