Prefilled and read only custom field

  • Posts: 126
  • Thank you received: 2
13 years 5 months ago #17561

Hello Nicolas,

I added a custom field to address table which should include user "username" data. I would like to auto complete this field and make it read only..how can i do that?

thank you

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 5 months ago #17564

There is no such option. Could you explain why you would like to do that ? There is probably another easier way to do it...

Please Log in or Create an account to join the conversation.

  • Posts: 126
  • Thank you received: 2
13 years 5 months ago #17578

Now only firstname and lastname are auto completed, but i need to get also the username.

When user has completed a new address, i would like to auto complete a custom field (named cod_agent) with his username. This custom field would be great to be read-only so user cannot change information.

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 5 months ago #17579

Could you explain what you do with that cod_agent field later on ? You could probably directly use the username from the joomla user table directly instead of having an additional field in the addresses for it.

Please Log in or Create an account to join the conversation.

  • Posts: 126
  • Thank you received: 2
13 years 5 months ago #17581

We use this site for our partners. Sometime, they use one general account(office) to make orders. What we need to do is to force user to login and make orders using their own account. It's a long story, trust me :)

Please Log in or Create an account to join the conversation.

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
13 years 5 months ago #17582

What I would do is this:
edit the file registration of the view user via the menu Display->Views and add the code:

if($fieldName=='cod_agent'){
$user =& JFactory::getUser();
$field->field_value = $user->username.'::'.$user->username;
}

just after the line: foreach($this->extraFields[$type] as $fieldName => $oneExtraField) {

and I would make that cod_agent field of the type dropdown or radio.
That should display in the registration form a radio/dropdown field with only one value which would be the username.

Please Log in or Create an account to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum