Meta Box
Support Forum
Support › MB Views › Label Not RenderedResolved
I've added this twig code to my MB View:
<div class="g-block size-100"> {% for item in post.notes_admin %} {{ item.label }} {% endfor %} {{ post.notes_admin }} </div>
However my label is not showing (the notes is 'hello' at the bottom) the label should read: Notes (admin only) https://thingsthatremain.org/message/the-way-of-the-rabbi/
Thanks
Hi,
If you are using the field type select, you can use the helper function rwmb_the_value() to show the label of the option.
select
rwmb_the_value()
Get more details on the documentation https://docs.metabox.io/fields/select/#template-usage https://docs.metabox.io/extensions/mb-views/#running-php-functions
Im not using select. I'm only using a standard text field. Please advise on how to best using Twig show the field label when a field is filled in. The documentation does not show it clearly. Thanks.
Please use the helper function rwmb_get_field_settings() to get the field’s settings: field’s name, field’s options (value, label) …
Here is the sample code
{% set my_text = mb.rwmb_get_field_settings( 'notes_admin' ) %} {{ my_text['name'] }}
Refer to this topic https://support.metabox.io/topic/show-label-of-select-chekbox-list/
Ok thanks - that was very helpful and I appreciate the documentation.