Placeholder?? Can't seem to get my own tables to work!??

Quality

Member
Placeholder??
Can't seem to get my own tables to work!??

Tried with:
{$my->id}
{$_SERVER->REMOTE_ADDR}

And it works!!

But when i try with {gls_fejlmelding___Oprettet_bruger_navn_} or any other it just show the kode!?:(

any help!? :rolleyes:
 
Where are you using the placeholders?
{gls_fejlmelding___Oprettet_bruger_navn_}
_ at the end is looking strange, is this your element name? Not sure if this may create issues.
 
It is working in an existing record (if this field is still empty), but I don't think it makes sense.
This "Placeholder" field is HTML5 only, displaying some sort of help text.
It's not setting any value, this has to be done in "Default" for new records.

What do you expect to be in a element placeholder in a new record.

What are you trying to achieve?
 
hi
The placeholders (the text inside the {} brackets) will only work for data in the current list. How is the data in the table kunde_profil related to this list's element? Is it that you want to include the current logged in user's 'address' that they have stored in that list?

If that's the case you will need to use some additional PHP to get that.

Lets presume that you have a field in kunde_profil called 'user_id' which stores the user's id. You will need to run a query to get the 'Adresse' for that user:

PHP:
// Get the database
$db = JFactory::getDbo();
 
// The current logged in Joomla user
$user = JFactory::getUser();
 
// Get the query
$query = $db->getQuery(true);
 
// Build the query
$query->select('Adresse')->from('kunde_profil')->where('user_id = ' . (int) $user->get('id');
 
Assign the query to the database
$db->setQuery($query);
 
// Load the first matched row's Adresse column
return $db->loadResult();
 
Hi :)

That is exactly what i want!:)

But i'm not sure where to put the kode...

do i just copy and paste to the php area in the element? sorry...o_O
 
woops yes it would help if I had told you were to put it! I did think it very loud, but I guess that doesn't count. ;)

It should go in the element's 'default' field, and you should also set 'eval default' = yes
 
Yes I thought so too but it does not seem to work?
is it me who is doing something wrong?o_O
 

Attachments

  • placeholder3.png
    placeholder3.png
    21.6 KB · Views: 298
Anyone who can tell me what i'm doing wrong!?
i need this to work so bad!! :(
 

Attachments

  • placeholder4.png
    placeholder4.png
    37.8 KB · Views: 257
Found it my self there was missing a " ) "

// Get the database
$db = JFactory::getDbo();

// The current logged in Joomla user
$user = JFactory::getUser();

// Get the query
$query = $db->getQuery(true);

// Build the query
$query->select('Adresse')->from('kunde_profil')->where('user_id = ' . (int) $user->get('id'));

//Assign the query to the database
$db->setQuery($query);

// Load the first matched row's Adresse column
return $db->loadResult();


Thank you now it works... :)
 
hi
The placeholders (the text inside the {} brackets) will only work for data in the current list. How is the data in the table kunde_profil related to this list's element? Is it that you want to include the current logged in user's 'address' that they have stored in that list?

If that's the case you will need to use some additional PHP to get that.

Lets presume that you have a field in kunde_profil called 'user_id' which stores the user's id. You will need to run a query to get the 'Adresse' for that user:

PHP:
// Get the database
$db = JFactory::getDbo();
 
// The current logged in Joomla user
$user = JFactory::getUser();
 
// Get the query
$query = $db->getQuery(true);
 
// Build the query
$query->select('Adresse')->from('kunde_profil')->where('user_id = ' . (int) $user->get('id');
 
Assign the query to the database
$db->setQuery($query);
 
// Load the first matched row's Adresse column
return $db->loadResult();



Is there any way to get it to look at the user in the field above and get it two show the address of the user and not change when the user change?
so you always know who has filled out the form!

don't now if you get what i meen!? ;)
 
hmm no i'm not sure thats possible, the default is only applied on a new record, so presumably the user element is either blank or set to the current user already (so making it the same user id as in the code previously posted)
You could have it so that the address changed when ever the user field's value was changed, by setting the address element to be a cascadingdropdown, but again I don't think this is what you are asking
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top