wpnzach
10/5/2016 - 8:14 PM

ninja-forms-prefill.js

// Create a new object for custom code.
var myCustomFieldController = Marionette.Object.extend( {
    initialize: function() {
		this.listenTo( Backbone.Radio.channel( 'app' ), 'after:loadControllers', this.changeValue );
    },

    changeValue: function() {
        var model = Backbone.Radio.channel( 'form-109' ).request( 'get:fieldByKey', 'textbox' );  //use your form number in place of '109' here.  Replace 'textbox' with your field key.  Field key must be unique per form and page, should a page contain multiple forms
        if ( model ) {
	        model.set( 'value', 'foo' ); // Update the value. Replace 'foo' with your value     	
        }
    }
});


jQuery( document ).ready( function() {
	new myCustomFieldController();
} );