Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I looked in the issue area for something that looked like it related to my question but I either don't know what terms to use or no one has really asked about it.
I have one select field called country where users need to pick their country. Then I have another field down farther was has to do with some engineering type stuff that has to have the same input as the country field. Is there a way that when they select a country, it pre-populates the other field below it?
I tried using this code here to at least ensure the same answer was typed in but it isn't working:
<?php
if ($form_values['submitted_tree']['country'] != $form_values['submitted_tree']['preferred_wri_code']) {
form_set_error('submitted][country', t('These country codes do not match. They must match before you can submit your form.'));
}
?>
Not sure why....
Becky
Comments
Comment #1
benone CreditAttribution: benone commentedHi, I am looking exactly the same option but for CCK form fields.
I have address, then I have another address field. I would like to copy the address from one field to another or put different address.
Anyway, subscribe.
Comment #2
quicksketchSupport for writing custom code is not provided in the Webform issue queue. Just a note that if you're using the 3.x version and have multiple pages, you can prepopulate the second field with the new %value token.
Comment #3
beckyjohnson CreditAttribution: beckyjohnson commentedOh ok, thanks for the tip about the %value token.