- Posts: 214
COMMUNITY FORUM
[SOLVED] Extra fields - default value as placeholder
- George Nasis
-
Topic Author
- Offline
- Elite Member
Less
More
11 years 1 month ago - 11 years 1 month ago #126854
by George Nasis
[SOLVED] Extra fields - default value as placeholder was created 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!
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.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 1 month ago #126855
by Lefteris
Replied by Lefteris on topic Re: Extra fields - default value as placeholder
Hi. No, unfortunately you cannot do this without hacking K2.
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
Less
More
- Posts: 214
11 years 1 month 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?
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.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 1 month ago #126857
by Lefteris
Replied by Lefteris on 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".
Please Log in or Create an account to join the conversation.
- George Nasis
-
Topic Author
- Offline
- Elite Member
Less
More
- Posts: 214
11 years 1 month 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
it is working perfect!
for everyone is interested just add
Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
11 years 1 month ago #126859
by Lefteris
Replied by Lefteris on topic Re: Extra fields - default value as placeholder
You are welcome.
Please Log in or Create an account to join the conversation.
- Lucas Gomes
-
- Offline
- New Member
Less
More
- Posts: 9
6 years 5 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.
- JoomlaWorks
-
- Offline
- Admin
Less
More
- Posts: 6227
6 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 :)
Please Log in or Create an account to join the conversation.
- Lucas Gomes
-
- Offline
- New Member
Less
More
- Posts: 9
6 years 4 months ago #170701
by Lucas Gomes
Replied by Lucas Gomes on 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>';
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.
- JoomlaWorks
-
- Offline
- Admin
Less
More
- Posts: 6227
6 years 4 months ago #170743
by JoomlaWorks
Replied by JoomlaWorks on 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.
Please Log in or Create an account to join the conversation.