[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".
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'];
}
}
}