Skip Navigation

[Resolved] Front-end form field descriptions

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

Problem:
The user would like to use the Toolset Types custom fields description in the Toolset forms as a hint

Solution:
The field descriptions is meant to be used in the backend editor as a hint for the custom fields. To reuse it inside forms, you can use the shortcode in this reply https://toolset.com/forums/topic/add-custom-fields-descriptions-to-a-form-as-a-shortcode/#post-1076230

This support ticket is created 3 years, 10 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9: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: Africa/Casablanca (GMT+01:00)

This topic contains 8 replies, has 2 voices.

Last updated by MikeS1622 3 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#1983961

I want to give the front end user some more information regarding a post form field.

I want to keep field names simple so they make sense after publishing the post content, and placeholder text is unique to certain field types and disappears if the field is partially filled in.

This seems so basic, so I feel like there an option somewhere that I have just missed?!

#1984047

Hello and thank you for contacting the Toolset support.

The cred_field shortcode that generates form fields accept a placeholder argument. For example:

[cred_field field='post_title' class='form-control' output='bootstrap' placeholder='Enter title here']

And this is the result hidden link

Read more about the shortcode here https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

#1984051

Thanks, as I mentioned the placeholder isn't going to work well enough for what I want due to it disappearing once they start filling in the field. I want to utilise the description (which is available on edit/create custom fields) and have it appear on the front-end post form.

Typically this would appear after the label, before the input field.

#1984795

I see what do you mean. Actually, these descriptions are not meant for Toolset Forms. They are intended to be displayed in the post editor screen of wp-admin. If you'd like to include these descriptions in the Toolset form, you must insert it manually. Or using a custom shortcode.

Our colleague Minesh has produced such a shortcode in this reply from a similar ticket https://toolset.com/forums/topic/add-custom-fields-descriptions-to-a-form-as-a-shortcode/#post-1076230

Let me know if that helps.

#1988809

Sorry, for the delay! Thanks, this useful. I'm still learning php, how would I wrap the returned description in a html tag, like a <p> for instance? I can't ask on the thread you linked to, so I'll put the php that gets added to the functions.php file here:

function func_display_types_field_desc($atts){ 
    $all_fields=get_option( "wpcf-fields" );
      
    $field = $atts['field'];
    $desc=$all_fields[$field]['description'];
    return $desc; 
}
add_shortcode( 'get_types_field_desc', 'func_display_types_field_desc');

If I can wrap it in a tag here then I can style it on the front end rather wrap every short code in a <p> tag which would take a while.

Ideally this should all be an option in the form editing page, at very least as a checkbox to say include description, but realistically being able to select things like above or below the input and the ability to add extra classes maybe. Could this be suggested as a feature?

#1989147

It was already suggested as a feature, but the developers have dropped it, as it was always intended for the backend.

Instead of getting the return from the shortcode wrapped in a <p> tag, put the shortcode inside a <p> tag:

<p>[get_types_field_desc  field="your-field-name"]</p>
#1989193

As I said in my previous message, that's going to be a really long way of doing it because I want to use the descriptions a lot.

#1989295

You can also update the code like so:

function func_display_types_field_desc($atts){ 
    $all_fields=get_option( "wpcf-fields" );
       
    $field = $atts['field'];
    $desc=$all_fields[$field]['description'];
    return '<p>' . $desc . '</p>';
}
add_shortcode( 'get_types_field_desc', 'func_display_types_field_desc');
#1989299

My issue is resolved now. Thank you!