Keyword

[SOLVED] Extra fields - default value as placeholder

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
4 years 9 months ago - 4 years 9 months ago #126854 by George Nasis
George Nasis created the topic: [SOLVED] Extra fields - default value as placeholder
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
4 years 9 months ago #126855 by Lefteris
Lefteris replied the topic: Re: Extra fields - default value as placeholder
Hi. No, unfortunately you cannot do this without hacking K2.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
4 years 9 months ago #126856 by George Nasis
George Nasis replied the 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
4 years 9 months ago #126857 by Lefteris
Lefteris replied the topic: Re: Extra fields - default value as placeholder
The fie that renders the extra fields is administrator/components/com_k2/models/extrafield.php. Look out for the function named "renderExtraField".

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
4 years 9 months ago #126858 by George Nasis
George Nasis replied the topic: Re: Extra fields - default value as placeholder
Thank you very much Lefteris!

it is working perfect!

for everyone is interested just add
placeholder="'.$extraField->name.'"

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

More
4 years 9 months ago #126859 by Lefteris
Lefteris replied the topic: Re: Extra fields - default value as placeholder
You are welcome.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

---
JoomlaWorks
www.joomlaworks.net/

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

More
1 month 2 days ago #170650 by Lucas Gomes
Lucas Gomes replied the 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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
4 weeks 1 day ago #170680 by Fotis
Fotis replied the topic: Re: Extra fields - default value as placeholder
Don't hack K2 core please :)


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

More
3 weeks 6 days ago #170701 by Lucas Gomes
Lucas Gomes replied the topic: [SOLVED] Extra fields - default value as placeholder
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.

  • Fotis
  • Fotis's Avatar
  • Offline
  • Administrator
  • JoomlaWorks Support Team
More
2 weeks 3 days ago #170743 by Fotis
Fotis replied the topic: [SOLVED] Extra fields - default value as placeholder
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.


If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

Moderators: william white