Home › Forums › Feature Requests › HTML5 placeholder tags
Tagged: html, HTML5, placeholder
- This topic has 4 replies, 3 voices, and was last updated 11 years, 4 months ago by Tralisk.
-
AuthorPosts
-
December 27, 2012 at 5:02 am #2715June 7, 2013 at 10:36 pm #3806bluantinooMember
hello everybody,
I’d like having placeholder instead of labels as well.anyway I’ve found this jQuery snippet to quickly transform labels into placeholders
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
source: https://gist.github.com/makeusabrew/985739
- This reply was modified 11 years, 5 months ago by bluantinoo.
- This reply was modified 11 years, 5 months ago by bluantinoo.
July 12, 2013 at 7:12 pm #3923TraliskMemberthis does not seem to work. I am trying to find where the plugin actually builds the <input items so i can add placehoder="" and use the field default value to populate the placeholder, but i cant find the part of the plugin that actually builds the elements of input.
July 12, 2013 at 7:26 pm #3924bluantinooMemberit would be nice to have some words from plugin developers, but it looks like they have nothing to say on this
July 12, 2013 at 7:56 pm #3925TraliskMemberIf anyone else is looking to do this, i have a solution where you can use the title as the placeholder text.
In plugins/user-meta/views/generateField.php around line 343 you have the start of the field value builder:
“value” => isset($field[‘field_value’]) ? $field[‘field_value’] : “”,
“label” => $fieldTitle,
“readonly” => !empty($fieldReadOnly) ? $fieldReadOnly : “”,
“disabled” => !empty($isDisabled) ? true : false,
“id” => $inputID,
“class” => $class,
“style” => @$inputStyle ? $inputStyle : “”,
“maxlength” => $maxlength,
“option_after” => isset($option_after) ? $option_after : “”,
“by_key” => $by_key,
“label_id” => $labelID,
“label_class” => $label_class,
“onblur” => isset($onBlur) ? $onBlur : “”,
“combind” => isset($combind) ? $combind : false,
“before” => $fieldBefore,
“placeholder” => $fieldTitle,
“after” => $fieldAfter,
//”enclose” => ! empty( $enclose ) ? $enclose : false,
), $fieldOptions );
}Above i have added “placeholder” => $fieldTitle, where i stole the $fieldtitle from the “label” in the first instance.
So thats how to do it, just took a while to find that this is where the attributes were being built, and i should have paid attention to Dreamweaver not allowing me to modify the plugin files while i was testing . . . make the change using WP editor if possible.
-
AuthorPosts
- You must be logged in to reply to this topic.