Keyword

[SOLVED] Extra fields - default value as placeholder

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 3 weeks ago - 10 years 3 weeks ago #126854 by George Nasis
Hallo there!

is there any way the default value(optional) of an extra field to be displayed as a placeholder???
Of course not in the k2 item.php where the item is displayed but when a user fills a form with the extra fields

Thank you very much!

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

More
10 years 3 weeks ago #126855 by Lefteris
Hi. No, unfortunately you cannot do this without hacking K2.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 3 weeks ago #126856 by George Nasis
Replied by George Nasis on topic Re: Extra fields - default value as placeholder
Hallo there

thanx for the response

i was sure that there is not a ready value for this.i mean by hacking the core.can you tell me where exactly to hack it to place the placeholder attribute?

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

More
10 years 3 weeks ago #126857 by Lefteris
The fie that renders the extra fields is administrator/components/com_k2/models/extrafield.php. Look out for the function named "renderExtraField".

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 3 weeks ago #126858 by George Nasis
Replied by George Nasis on topic Re: Extra fields - default value as placeholder
Thank you very much Lefteris!

it is working perfect!

for everyone is interested just add
Log in  or Create an account to join the conversation.

More
10 years 3 weeks ago #126859 by Lefteris
You are welcome.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
5 years 4 months ago #170650 by Lucas Gomes
Replied by Lucas Gomes on topic Re: Extra fields - default value as placeholder
Where the line you insert this placeholder="'.$extraField->name.'"?

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

More
5 years 4 months ago #170680 by JoomlaWorks
Replied by JoomlaWorks on topic Re: Extra fields - default value as placeholder
Don't hack K2 core please :)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
5 years 4 months ago #170701 by Lucas Gomes
The file path is administrator>components> com_k2>models> extrafield.php

For the text area field type, find this line:
$output = '<textarea name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" rows="'.$active[2].'" cols="'.$active[3].'" '.$attributes.'>'.htmlspecialchars($active[0], ENT_QUOTES, 'UTF-8').'</textarea>';

Insert this line BEFORE it:
$attributes .= ' placeholder="'. $extraField->name .'"';

So the final code will be like this:
$attributes .= ' placeholder="'. $extraField->name .'"';
$output = '<textarea name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" rows="'.$active[2].'" cols="'.$active[3].'" '.$attributes.'>'.htmlspecialchars($active[0], ENT_QUOTES, 'UTF-8').'</textarea>';

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

More
5 years 3 months ago #170743 by JoomlaWorks
As mentioned in the other post you made, this will be properly added in K2 v2.11 with separate placeholder field to add whatever you want as field indicator.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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