Hi,
Just started using chronoforms and need help as below:
I have created a form with various fields including username and email
what i would like is to assign the logged in user/email to username and email
So when the form is displayed it should automatically display the name value and
email plus the other input fields which the user needs to key in data.
I would appreciate anyone who can walk me through this.
Thank you
Just started using chronoforms and need help as below:
I have created a form with various fields including username and email
what i would like is to assign the logged in user/email to username and email
So when the form is displayed it should automatically display the name value and
email plus the other input fields which the user needs to key in data.
I would appreciate anyone who can walk me through this.
Thank you
SPABO
The username and email details should be from the registered users in Joomla.
i.e. from the Current User Object
I am able to get the user and email using:
$user =& JFactory::getUser();
$txtname=$user->username (if i echo $txtname it displayed the current logged in user's username)
$txtemail=$user->email (if i echo $txtemail it displayed the current logged in user's email)
The problem is i do not know which file or parameters to edit to assign these
values to the fieldnames that i have created in the forms.
Any assistance is much appreciated.
TQ
The username and email details should be from the registered users in Joomla.
i.e. from the Current User Object
I am able to get the user and email using:
$user =& JFactory::getUser();
$txtname=$user->username (if i echo $txtname it displayed the current logged in user's username)
$txtemail=$user->email (if i echo $txtemail it displayed the current logged in user's email)
The problem is i do not know which file or parameters to edit to assign these
values to the fieldnames that i have created in the forms.
Any assistance is much appreciated.
TQ
Hi dalone,
You can assign these as values for text inputs --BUT you don't want to do this as you don't want the user to try to change their name or email form this form (unless you have the back end set up to edit the Joomla user records correctly).
Best just to echo the data in the form as you have done. ChronoForms saves the current user id in the database table so you can always use that to get the user name and email if you need it.
Bob
You can assign these as values for text inputs --BUT you don't want to do this as you don't want the user to try to change their name or email form this form (unless you have the back end set up to edit the Joomla user records correctly).
Best just to echo the data in the form as you have done. ChronoForms saves the current user id in the database table so you can always use that to get the user name and email if you need it.
Bob
Hi Bob,
Yes, i did use the value in input as below:
<input class="cf_inputbox validate-alpha" maxlength="150" size="30" title="" id="text_7" name="frm_name" type="text" value="<?php $user = &JFactory::getUser();echo $user->name;?>" />
And as you said i found that default values were editable, so i tried the code below:
<input class="cf_inputbox validate-alpha" maxlength="150" size="30" title="" id="text_7" name="frm_name" type="text" value="<?php $user = &JFactory::getUser();echo $user->name;?>" disabled="disabled" />
It was displaying my default fields and it was not editable. I was happy until i found out that when the field is disabled the value is NOT stored in the database. then i tried the code below:
The code with the readonly parameter worked perfectly.
So essentially to assign default values to form fields the process is as below:
1. Click on the form you had created
2. Click on "Form Code"
3. For each of the "Form Item" where the field for the default value is
add the "value" parameter with the getuser()attribute that is relevant
..i.e. $user->name, $user->email..etc..
4. Also add readonly parameter for each form item which requires a default value
Thanks Bob and luykmhm(http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=7&t=4539#p4539) for your assistance
Hope this post helps others , as i had spent quite a bit on time getting it to work.
Regards
dalone
Yes, i did use the value in input as below:
<input class="cf_inputbox validate-alpha" maxlength="150" size="30" title="" id="text_7" name="frm_name" type="text" value="<?php $user = &JFactory::getUser();echo $user->name;?>" />
And as you said i found that default values were editable, so i tried the code below:
<input class="cf_inputbox validate-alpha" maxlength="150" size="30" title="" id="text_7" name="frm_name" type="text" value="<?php $user = &JFactory::getUser();echo $user->name;?>" disabled="disabled" />
It was displaying my default fields and it was not editable. I was happy until i found out that when the field is disabled the value is NOT stored in the database. then i tried the code below:
<input class="cf_inputbox validate-alpha" maxlength="150" size="30" title="" id="text_7" name="frm_name" type="text" value="<?php $user = &JFactory::getUser();echo $user->name;?>" readonly="readonly" />
The code with the readonly parameter worked perfectly.
So essentially to assign default values to form fields the process is as below:
1. Click on the form you had created
2. Click on "Form Code"
3. For each of the "Form Item" where the field for the default value is
add the "value" parameter with the getuser()attribute that is relevant
..i.e. $user->name, $user->email..etc..
4. Also add readonly parameter for each form item which requires a default value
Thanks Bob and luykmhm(http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=7&t=4539#p4539) for your assistance
Hope this post helps others , as i had spent quite a bit on time getting it to work.
Regards
dalone
Thanks to Jesus, dalone, Bob and the Google bot for sharing this.
- Mike
- Mike
Hi Mike,
If you take the new ChronoSearch link from the Tutorials menu above you'll find a custom Google Search for ChronoForms. Makes my life a little easier.
Bob
If you take the new ChronoSearch link from the Tutorials menu above you'll find a custom Google Search for ChronoForms. Makes my life a little easier.
Bob
This is too cool.
a'la Gandalf I was going to elevate you from grey to white, only to end up with WhiteHead, which isn't cool so lets just go for GoldHead, i.e thanks again for your patience and freely given support.
a'la Gandalf I was going to elevate you from grey to white, only to end up with WhiteHead, which isn't cool so lets just go for GoldHead, i.e thanks again for your patience and freely given support.
This topic is locked and no more replies can be posted.