Skip Navigation

[Resolved] rename No Parent text

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

Problem:
How to change the "No parent" text in select a parent from a drop down field.
Solution:
Use no_parent_text='Your text' in the field shortcote.

This support ticket is created 8 years, 1 month 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 14:00 8:00 – 14:00 8:00 – 14:00 8:00 – 14:00 8:00 – 14:00 - -
15:00 – 17:00 15:00 – 17:00 15:00 – 17:00 15:00 – 17:00 15:00 – 17:00 - -

Supporter timezone: Asia/Jerusalem (GMT+03:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by nabils 8 years ago.

Assisted by: Itamar.

Author
Posts
#381768

I am trying to: I have a cred where I have to select a parent from a drop menu list. Works fine, but this "No parent" option is annoying. I am trying to change the text "No parent" to "select...". Any clue please? I found one post in the forum about the same issue but it does not give a solution
Thank you

#381770

I added this JS:
jQuery(document).ready(function($) {
id = jQuery('select[name="_wpcf_belongs_acad-years_id"]').attr('id');

jQuery("#"+id +" option[value='-1']").text('select');

});
and it works, but is there an easier way from Toolset options?

#382121

Itamar
Supporter

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hello, Nabils.

Welcome to the Toolset support forum.

I would like to thank you for pointing this issue to us at the support forum and I’ll report this as a feature request if its possible to add “No Parent” text to CRED form text block.

I'll ask our developers to add an extra option to enable "No parent" to be changed to whatever the user chooses.

Meanwhile please keep using your JS workaround.
I'll keep you posted when I'll hear back on this subject from our developers.

Please let me know if you need further info about this.

Thanks,
Itamar.

#383695

Itamar
Supporter

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Nabils.

I gave another shot at this issue, and I would like to ask you to try and add the following attribute to your field shortcode.

no_parent_text='Select'

Select should replace the "No parent" text.

Your shortcode should then look something like that.

[cred_field field='_wpcf_belongs_book_id' value='' order='date' ordering='desc' no_parent_text='Select']

Please let me know if the above solution works for you, I look forward to your reply!

Thanks,
Itamar.

#384668

Dear Itamar,
Thanks for the following up. Yes, indeed, it works! However, how do I force the user to select a value other than "Select" for this parent field?

Regards
Nabil

#384752

Actually, I did it with the validation Hook (see below), but is there a straightforward method?
add_filter('cred_form_validate','my_validation',10,2);
function my_validation($field_data, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$field_data;

//uncomment this if you want to print the field values
//print_r($fields);

//validate if specific form
if ($form_data['id']==524)
{
//check my_field value
if ($fields['_wpcf_belongs_acad-years_id']['value']!='Select')
{
//set error message for my_field
$errors['_wpcf_belongs_acad-years_id']='Please select an academic year!';
}

}

//return result
return array($fields,$errors);
}

#384876

Sorry there was an error in the previous code. I should be:

....
if (isset($fields['_wpcf_belongs_acad-years_id']['value']) && $fields['_wpcf_belongs_acad-years_id']['value'] == "-1")
{
//set error message for my_field
$errors['_wpcf_belongs_acad-years_id']='Please select an academic year!';
}
....

#385482

Itamar
Supporter

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Nabils.

I'm glad that you could come up with the validation hook solution.

Unfortunately, there is no a more straightforward method for that.

Please let me know if you need further info about this.

Thanks,
Itamar.

#388598

Thank you

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