[Resolved] 2 same mandatory field in the same cred
This thread is resolved. Here is a description of the problem and solution.
Problem:
make 2 same identical fields with the mandatory field and validate in the same cred form
Solution:
You can add another field using Generic field and later once it passes the validation, use the Forms hook cred_before_save_data to assign the value to original field "wpcf-contraente".
This support ticket is created 4 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.
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.
Hello i setup 2 radio fields:
1. radio field: cliente (values "privato" or "business")
2. simple text 1 row: codice-fiscale-o-partita-iva (mandatory field)
I want to obtain this result:
if radio field selected is "privato"
label: "codice fiscale" - input field "codice-fiscale-o-partita-iva"
if radio field selected is "business"
label: "partita iva" - input field "codice-fiscale-o-partita-iva"
I'm using correctly conditional show group and mandatory check in my custom fields, effectively is working all good.
My problem is that using twice in same cred field "codice-fiscale-o-partita-iva" this field is not mandatory anymore.
If i use only one time is working good.
Hello. Thank you for contacting the Toolset support.
Well - I review your requirement and I can see that you just want to change the label according to your selection - is it correct? If yes:
Could you please share problem URL where you added your form and access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
add_action('cred_before_save_data', 'func_assign_field_value',10,1);
function func_assign_field_value($form_data)
{
// if a specific form
if ($form_data['id']==62)
{
if (isset($_POST['wpcf-contraente1'])) {
$_POST['wpcf-contraente'] = $_POST['wpcf-contraente1'];
}
}
}