I have Ninja Forms and ACF for WordPress installed. I have a hidden field in Ninja Forms and I need to repopulate this with the value from an ACF field.
I tried simple jQuery but it doesn't work:
$('input[name=nf-field-19]').val('<?php the_field('rsvp_email'); ?>');
As you can tell.. I'm no PHP or jQuery guy.. trying to fiddle around and find a solution.
Thanks!
You'll want to make sure you add a hidden field to your form first and leave the Default Value empty. Once your users submit your form, you can navigate to Ninja Forms > Submissions and select the submission where you would like to add some extra notes. Click Edit. This will open a pop-up with user-submitted values.
Make sure the Value of your form fields is filled out. Then you'll want to head to the Advanced tab and select Conditional Logic. Here you can add conditions for your form fields. That's it! You've just learned how to create dynamic fields and show the fields based on the user's input on your form.
Creating a Multi Step FormStart by adding fields to the first part of your form. Once you add a field, you should see a grey circle/+ sign show up in the bottom right of the form builder. Once the part is added, you can then edit its settings by clicking on the tab that appears at the bottom of the screen.
Do you need this to work from JS for some reason? I am using the ninja_forms_render_default_value
filter hook to prepopulate hidden form fields:
/**
* Populate hidden input with ACF values
*/
function nf_hidden_field_values( $value, $field_type, $field_settings ) {
global $post;
$value = ''
if ( $field_settings['key'] == 'hidden_field_1' ) {
$value = get_field('acf_field_1', $post->ID);
}
if ( $field_settings['key'] == 'hidden_field_2' ) {
$value = get_field('acf_field_2', $post->ID);
}
return $value;
}
add_filter( 'ninja_forms_render_default_value', 'nf_hidden_field_values', 10, 3 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With