Suggestion for fields — Automatically adding a TITLE ATRIBUTE based on MB ID
Support › General › Suggestion for fields — Automatically adding a TITLE ATRIBUTE based on MB IDResolved
- This topic has 6 replies, 2 voices, and was last updated 4 years, 5 months ago by
Teia Local Studio.
-
AuthorPosts
-
December 7, 2020 at 7:15 AM #23431
Teia Local Studio
ParticipantHello guys!
I have a suggestion for future MetaBox versions — is it possible to add a TITLE attribute automatically based on the ID of a metabox field? It is super useful when you are developing interfaces based on metaboxes.
You just move the cursor on top of it and the browser tooltip refreshes your memory with a instantaneous info!
Otherwise you need to check the source code or use other cluttering tools for a so simple process.
When editing in admin metaboxes fields are generated this way:
<input size="30" type="text" id="famicom" class="rwmb-text" name="famicom" />
My suggestion:
<input size="30" type="text" id="famicom" class="rwmb-text" name="famicom" title="famicom" />
Where the "title" attribute is equal as the field ID. And of course, to apply not only on INPUT:text, but also in all kind of fields generated by MB plugin!
What do you think?
Thank you so much for this wonderful suite of MAGIC!
Love metaBox!G.
December 7, 2020 at 7:52 AM #23432Teia Local Studio
ParticipantWell,
I just accomplished a satisfactory result injecting some custom jQuery on WordPress admin. Using the code below I can force the most common fields to have a TITLE attribute based on their IDs:
jQuery('input, textarea, select, .wp-color-picker').each(function(){ jQuery(this).attr('title', jQuery(this).attr('id')); }); jQuery('.rwmb-switch').each(function(){ jQuery(this).next().attr('title', jQuery(this).attr('id')); }); jQuery('label').each(function(){ jQuery(this).attr('title', jQuery(this).attr('for')); });
Hope to be useful to someone!
G.December 7, 2020 at 10:08 AM #23434Long Nguyen
ModeratorHi Giovani,
Thanks for your idea.
WordPress requires the meta box's title when registering, we've also noted this case on the documentation when creating the meta box:
id
Meta box ID, must be unique. Optional. If it’s absent, it will be generated fromtitle
usingsanitize_title
function.
title
Meta box title. Required.https://docs.metabox.io/creating-meta-boxes/#meta-box-settings
title
is required andid
is optional, it will be generated fromtitle
.December 7, 2020 at 6:03 PM #23442Teia Local Studio
ParticipantHello, Long.
Yes yes, I understand perfectly, but I was talking about the attribute title IN A FIELD itself, not the general title of a array of fields — the whole metabox thing.
My suggestion:
<img id="my-id" src="xxx" alt="abc" TITLE="my-id" /> <input type="text" id="my-id2" size="30" TITLE="my-id2" /> <select id="my-id3" name="pick-a-boo" title="my-id3"> ... </select>
What we have today:
<img id="my-id" src="xxx" alt="abc" /> <input type="text" id="my-id2" size="30" /> <select id="my-id3" name="pick-a-boo"> ... </select>
It could be added on the metabox root code, however I can'r mess up the core code there, because it will me lost upon updating:
if ( class_exists( 'RWMB_Field' ) ) { class RWMB_Phone_Field extends RWMB_Field { public static function html( $meta, $field ) { return sprintf( '<input type="tel" name="%s" id="%s" value="%s" title="%s">', $field['field_name'], $field['id'], $meta, $field['id'] // <------- THIS ); } } }
Well, just and idea. I found a workaround using jQuery, but it would be great to have this implemented, at least on INPUT, SELECT, TEXTAREA.
Thank you!
December 7, 2020 at 7:01 PM #23445Teia Local Studio
ParticipantThis:
And this:
=)
December 8, 2020 at 9:44 PM #23474Long Nguyen
ModeratorHi,
Thanks for your effort.
The attribute title for each field helps users to show the short description when hovering the element. We also have the extension MB Tooltip to show the description as well.
But I will discuss with the developer team to take a look at this case and support in the future update if needed.
December 8, 2020 at 9:52 PM #23475Teia Local Studio
ParticipantOh!
Metabox TOOLTIP. I was completely unaware of this extension. Thanks for the suggestion. Really nice indeed!
Best regards,
G. -
AuthorPosts
- You must be logged in to reply to this topic.