Skip Navigation

[Resolved] Arguments in types_render_field() are ignored since Types v3.x

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

Problem:
Types 3 included a rewrite of the types_render_field function (part of the Types API which also underpins the types shortcode) and some of the arguments which used to work no longer do.

Solution:
This was unintended. After several tries to catch edge cases the existing arguments should continue to work as before in Types 3.0.6+

This support ticket is created 6 years, 5 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 14 replies, has 3 voices.

Last updated by Matthias 6 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#916547
types-3x-bad.png
types-29x-good.png

Hi,

I have set up some custom fields and outpout these in my theme like this:

<div class="ad-details">
    <?php echo types_render_field( "plz", array( "output" => "html", "show_name" => "true" )); ?>
    <?php echo types_render_field( "ort", array( "output" => "html", "show_name" => "true" )); ?>
    <?php echo types_render_field( "telefon", array( "output" => "html", "show_name" => "true" )); ?>
</div>

Since Version 3.x the arguments are ignored. The wrapping HTML Tags for field name and field value are missing. The functions just outputs the raw value. See the screenshots.

Best regards
Matthias

#916627

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Matthias

I tested this locally and confirm the problem.

I have escalated this so that my colleagues can identify the cause so that it can be fixed, and I'll update you as soon as I have any news.

#921650

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Matthias

Just to let you know this was fixed with an update to Types 3.0.2 earlier this week.

If you have updated already you will hopefully have noticed the update.

#921675
types-302-still-bad.jpg

Hello Nigel,

thank you for the info. I updated the plugin but the field names (argument "show_name") are still missing. See the new screenshot.

Best
Matthias

#921698

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Matthias

It is not documented that you can use the show_name argument (https://toolset.com/documentation/customizing-sites-using-php/functions/), but is it something that used to work for you which stopped working in Types 3?

I can see that it doesn't work, but what is unclear is whether it is expected to work or not.

If you can confirm a Types version where it used to work, please let me know the version number, and the kind of Types field you are using.

I can then escalate this as a bug.

If you would like it to work but it never did work, then I'll handle it as a feature request.

#921734
types-232-single-line-show_name.jpg

Hi Nigel,

it works in Types 2.3.2. I use a simple text field here. See another screenshot.
For the code in my theme and a screenshot of the output see my first post in this thread.

Cheers,
Matthias

#921760

Hi

I'm having exactly the same problem and I've now got a customer site that is missing a lot of labels on the reports.

It's worked fine for years, and it used to be in the documentation (or I wouldn't have found it). You have shown people in the forums how to use "show_name" in the past as well: https://toolset.com/forums/topic/hide-field-label-from-when-using-show_name-true-attribute-in-types/

It needs to be put back in as a matter of urgency.

Regards

Iain

#921761

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Matthias

You are right, I checked and it works pre-Types 3.

However, it is not documented, but in any case I'm escalating this so that the developers can take a look and see why it stopped working with the changes in Types 3.

Note that as a workaround you can, of course, simply insert text ahead of the field value directly in the PHP template.

#921762

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Iain

I've just seen your comment, and it's duly noted, this will be raised at the developer meeting Monday morning.

#921784

Thanks Nigel.

I've also tried using the "output"=> "html" parameter, as this was supposed to add the field label. This doesn't seem to work either.

I've spend a while looking at the source code, and I notice that types_render_field has internally been replaced with types_render_postmeta which doesn't have the same functionality.

Regards

Iain

#954336

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Our devs revisited this, and whereas the show_name attribute was available somewhat arbitrarily on some types of custom fields but not others, it has now been updated to work on all fields where it makes sense.

We released Types 3.0.6 yesterday with this fix. Please update and let me know if you still have problems with it.

#954359
toolset-types-306.png

Hello Nigel,

thank you for the update.

The field name is back but unfortunately, it's not wrapped in a <span>-Tag as in version 2.3.2. Please see the screenshot in my 1st post in this thread: hidden link

The HTML tags looked like this in all version < 3.x:

<div id="wpcf-field-XYZ" class="wpcf-field-textfield wpcf-field-XYZ">
	<span class="wpcf-field-name wpcf-field-textfield wpcf-field-XYZ-name">XYZ:</span>
	<span class="wpcf-field-value wpcf-field-textfield-value wpcf-field-XYZ-value">some value</span>
</div>

In version 3.0.6 the field name is outside the wrapping div and it's not wrapped in a span.

Best regards,
Matthias

#954384

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You are correct, when used in conjunction with the output="html" attribute the markup is not correct.

I'm guessing it was tested in isolation and not in that combination.

I have re-opened the internal ticket and asked the developers to look again.

#956436

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Matthias

They took another look at this and the show_name attribute should work correctly when used in combination with output="html" in the next version of Types.

In the meantime a patch is available as described here: https://toolset.com/errata/types-fields-are-not-displayed-properly-using-types_render_field/

Sorry for the inconvenience.

#958722

The patch fixes the problem. Thank you for your help, Nigel!