Skip Navigation

[Resolved] No control over output of Field name on render field

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to hide the field name label of the select dropdown while displaying on frontend using Types PHP API function types_render_field().

Solution:
You can use the field attribute 'show_name' => 'false' to hide the field name.

You can find proposed solution in this case with the following reply:
https://toolset.com/forums/topic/no-control-over-output-of-field-name-on-render-field/#post-1759135

Relevant Documentation:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by michaelT-3 3 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1757213
Screen Shot 2020-08-25 at 8.44.29 PM.jpg

I am trying to: output the field display name for a dropdown item

Link to a page where the issue can be seen: see attached image, site is password protected

I expected to see: "Federal Comment Letter"

Instead, I got: "Resource-type: Federal Comment Letter"

I have the render set as <?php echo types_render_field('resource-type',array( 'show_name' => 'true', 'output'=>'normal' ));?>

show_name is working exactly as I expected in outputting the field name, but "raw", "normal" and "html" have no effect on the output of "Resource-type:" which I do not want to show.

#1757873

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

The "show_name" attribute display the field name. you want to display the field name or not?

Please check the "show_name" attribute available with every field:
=> https://toolset.com/documentation/customizing-sites-using-php/functions/

Can you please confirm if you want to display the field name or not?

#1758165

As I said: "show_name is working exactly as I expected in outputting the field name, but "raw", "normal" and "html" have no effect on the output of "Resource-type:" which I do not want to show."

The problem is not show_name. The problem is the label that is being applied to the field name.

"Resource-type:" is the problem and there appears to be no way to suppress that.

#1759111

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please tell me what issue you are having with outputting "raw", "normal" and "html"- do you mean the field is not displaying the correct value?

#1759127

This code: <?php echo types_render_field('resource-type',array( 'show_name' => 'true', 'output'=>'normal' ));?>

Outputs "Resource-type:" in front of the field name regardless of whether "output" is set to raw, normal or html. Doesn't matter. It outputs the label regardless.

Raw = "Resource-type: reg-comment-letter"
Normal = "Resource-type: Regulatory Comment Letter"
HTML = "Resource-type: Regulatory Comment Letter"

See the problem? You cannot remove the label "Resource-type: " from the output regardless of what you set for output.

#1759135

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you try the following code:

<?php echo types_render_field('resource-type',array(  'output'=>'normal' ));?>

or

<?php echo types_render_field('resource-type',array( 'show_name' => 'false', 'output'=>'normal' ));?>

Does that help to remove the field name Resource-type: from the output?

#1759601

The first line worked. Including show_name doesn't actually show the name, it shows the meta_key, rather than the display value associated with the meta_value. However, it shows the meta_key with capitalization and the colon. That seems to be badly explained in the documentation for types_render_field.

#1759607

My issue is resolved now. Thank you!

The documentation of types_render_field explains the use of show_name very poorly.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.