Forums

Profile editable enabled stops getUser working

2020media 27 Jul, 2010
Hi
Sorry to post this if it's obvious. Have spent an afternoon looking through the forums but no luck!

I am using Profile plugin to pull in some data from my own table called xyz. I am also populating some form fields with &JFactory::getUser. This works fine, displaying both the data from the xyz table, and the Joomla User name.

When I submit the form, I want it to update (not insert a new row) my xyz table.

Reading the forums, I thought the way to do this was to change the profile plugin setting

Editable -> On

However when i do this, the &JFactory::getUser becomes blank. So then I changed

Evalute -> On

but it makes no difference - field thats supposed to display &JFactory::getUser still blank.

Here's the relavant part of my form HTML that is supposed to pull in the username:

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Email Address</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_2" name="text_2" type="text" value="<?php $user = &JFactory::getUser();echo $user->email;?>" readonly="readonly"/>
  
  </div>
  <div class="cfclear"> </div>
</div>



This part pulls in the data from the xyz table

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Domain Name</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_5" name="domain_name" type="text" value="{domain_name}" readonly="readonly"/>
  
  </div>
  <div class="cfclear"> </div>
</div>


Many thanks for any help.

Rex
GreyHead 28 Jul, 2010
Hi Rex,

To get a record to update you have to include the primary key value in the form results. The usual way to do that is to add it in a hidden input.

Bob
2020media 28 Jul, 2010
Thank you

Any idea why the fields that are using &JFactory::getUser go blank when I turn on Editable and/or evaluate?

regards
Rex
GreyHead 28 Jul, 2010
Hi Rex,

None at all. I guess it has something to do with the code that ChronoForms tries to use to create editable fields.

Bob
nml375 28 Jul, 2010
Hi Rex & Bob,
Have you tried adding the text_2 input to the 'Skipped Fields List' in your Profile plugin setup?
What I believe is happening, is that the JFactory::getuser() method fetches the user object properly, and prints the email address as intended. However, as the "edit profile code" kicks in, it will actually replace this with whatever value it was able to retrieve from the database (or '' if there was no value with this name in the dataset).

/Fredrik
2020media 28 Jul, 2010
Fredrik - thanks you are correct.

I've added the fields text_2 to the skipped fields section of the Profile plugin and now it's working as expected.

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