New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser autocomplete is off. Is there a way to turn it on? #3428

Closed
cmendla opened this Issue Mar 10, 2018 · 4 comments

Comments

Projects
None yet
5 participants
@cmendla
Copy link

cmendla commented Mar 10, 2018

  • What actions are you taking?
    Browser autocomplete is not working. This is problematical for emails. Apparently issues #231 and #2171 requested the ability to turn the browser autocomplete off. From what I can see it is off but I don't see a way to turn it on . This poses a problem for users on mobile devices. Worst case, stanislaus..pavel.wochiezski@mylongdomainname.com has to type his address in on his android instead of using the browser autocomplete.

  • What had happened was...
    no browser autocomplete

  • What are you expecting to occur?
    Browser autocomplete.

  1. Is there an option to turn browser autocomplete on ?
  2. If not, can this be added as an enhancement?

thanks, Chris

@wpnzach

This comment has been minimized.

Copy link
Contributor

wpnzach commented Mar 12, 2018

The issue is more complex than just enabling autocomplete, unfortunately. Currently, Ninja Forms 3.0 doesn't output form tags. As a result, even with autocomplete enabled, it doesn't work in any modern browsers. When form tags are added, other issues occurred causing breakage. This is being looked into, but ended up being more complex than originally thought. We should be about a month out.

@wpnzach wpnzach closed this Mar 12, 2018

@tantuohy

This comment has been minimized.

Copy link

tantuohy commented Mar 20, 2018

So has anyone implemented a successful workaround?

@AdilAliUK

This comment has been minimized.

Copy link

AdilAliUK commented Mar 25, 2018

I am also having the same issue, I'd love to know when this will be updated.

@modelm

This comment has been minimized.

Copy link

modelm commented Apr 17, 2018

For those tracking this issue, it looks like 3.2.17 includes autocomplete according to the changelog on https://wordpress.org/plugins/ninja-forms/#developers : Form autocomplete is here!

ETA this didn't work as I'd hoped, since only values you've submitted in other forms show up as autocomplete options on ninja forms. I needed values entered on a particular ninja form to autocomplete when filling out the same form again. Here is my extremely hacky solution using an empty iframe to fool the browser into saving the form data for autocomplete:

/**
 * Add the ninja forms autocomplete hook to the footer.
 */
function hcommons_ninja_forms_autocomplete() {
	$print_js = function() {
		?>
		<iframe name="ninja-forms-autocomplete" style="display:none" src="https://about:blank"></iframe>
		<script>
		jQuery( function( $ ) {
				if ( 'object' !== typeof Marionette ) {
					return;
				};
				var HcNfAutocomplete = Marionette.Object.extend( {
					initialize: function() {
						this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit );
					},
					actionSubmit: function( response ) {
						$( '.nf-form-wrap form' )
							.attr( 'target', 'ninja-forms-autocomplete' )
							.attr( 'action', '/robots.txt' ) // This doesn't do anything except fool browsers with a 200 OK response.
							[0].submit();
					},
				});
				new HcNfAutocomplete();
		} );
		</script>
		<?php
	};

	add_action( 'wp_footer', $print_js, 100 );
}

// Run only on nf_init so as not to embed JS where the plugin isn't active.
add_action( 'nf_init', 'hcommons_ninja_forms_autocomplete' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment