Support » Plugin: Gravity Forms Sisyphus » Dynamically populated field

  • Resolved aliferis

    (@aliferis)


    Hi there

    I love this addon however I have a small problem:

    When I try to use a dynamically populated field (with a query var) it does not work when Sisyphus is actived for the form

    In other words, I cannot pass a get variable to a form field

    Can this be fixed or worked around ?

    I really need to be able to send the user away from their form to choose something then redirect them back, passing a get variable to the form to populate a text field

    help !

    joe

    https://wordpress.org/plugins/gravity-forms-sisyphus/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author B Hays

    (@benhays)

    Hi Joe,

    Can you explain the process of your form a bit more?

    The user is sent away, then comes back with a new value passed by a query var. Is the query var is not being saved by Sisyphus? or the query var does not even show up in the form field?

    The user starts at a Gform and inputs some data into a few fields, then, using conditional logic, I show them a link to or redirect them to a custom post type archive, where they do a faceted filter search on posts using custom taxonomy’s. They then click a post title to choose a post – this links back to the Gform and adds the post title as a get variable – the intention being for the form to pick up the var and add it to a text field. Then the user continues filling out the form and submits.

    The key feature I need from your plugin is for it to retain the data entered into fields before the user was redirected away to the post archive, so that when they return to the form with the get var, the already filled in data is retained.

    This all works, however, when the Sisyphus option is active in the forms settings, the form does not get the variable into my text field (that has dynamically populated field option on)

    make sense ?

    thanks a lot

    joe

    So, in other words, it seems as if this method does not work when Sisyphus option is active for a form

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_the_Post_Author

    Plugin Author B Hays

    (@benhays)

    Thanks, that does make sense.

    From what I can tell, Sisyphus is overwriting your newly passed value with the previously saved empty value.

    Sisyphus has an onRestore function that could likely be called to then populate the field in question, however, this is beyond the scope of the plugin.

    Hope this helps.

    I see – thanks

    I’ll see if I can solve it and get back to you

    Rgds

    joe

    What about something like this in my functions file:

    7 = ID of form

    add_filter(‘gform_pre_render_7’, ‘populate_form_pre_render’);

    function populate_form_pre_render($form){
    $name =”;
    foreach ($form[‘fields’] as &$field)
    {
    // replace 2 with the actual ID of your form field
    if ( 2 == $field[‘id’] ){
    if ( ! empty( $_GET[‘boilermodel’] ) ) {
    $name = $_GET[‘boilermodel’];
    //var_dump( $name );
    }
    $field[‘defaultValue’]=$name;
    echo ‘

    ';
      print_r($field);
      echo '

    ‘;
    }

    }

    return $form;
    }

    this in the functions file works in one sense – that it gives a specific field in a specific form a default value

    add_filter('gform_field_value_input_6_3', 'input_6_3_population');
    function input_6_3_population(){
    
    // if we have a get variable set it to field value
    if ( $_GET['boilermodel'] ){
    $model = $_GET['boilermodel'];
    }
    // Return it
    return $model;
    }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    If you plugin could leave fields with default values set untouched then the solution would work

    Rgds

    joe

    Actually, I think it might be working …

    actually – its not

    there is a clear conflict between the persistence mode and passing a variable to a field dynamically

    Joe

    Plugin Author B Hays

    (@benhays)

    I think the only solution at this point is to forgo my plugin and add the Sisyphus plugin yourself for that form. Then you can specify how you want to handle that field.

    Sisyphus does have the ability to exclude fields. That could result in some problems with that field not being saved, but if the passing of the value is more important, it could be a good tradeoff.

    I didn’t write Sisyphus, I only set things up so it works with Gravity Forms. You can find more information on Sisyphus here: http://sisyphus-js.herokuapp.com/

    thanks for the help

    I edited the plugin – found and changed this block – adding this to the end: .not( “#input_6_5” ) – but to no avail

    ————————————————————

    findFieldsToProtect: function( target ) {
    return target.find( “:input” ).not( “:submit” ).not( “:reset” ).not( “:button” ).not( “:file” ).not( “:password” ).not( “:disabled” ).not( “[readonly]” ).not( “.gform_next_button” ).not( “gform_previous_button”).not( “.gform_hidden” ).not( “#input_6_5” );
    },

    actually the above does work – I had added it to the js file whilst the plugin used the js min file

    working now

    so, in summary, you can exclude specific form/fields using this approach (modifying the above array in the plugins js file)

    thanks for your help

    joe

    Plugin Author B Hays

    (@benhays)

    That’s great, glad you got it working.

    Hi,

    I’m struggling with this exact same problem. The solution to exclude this field in sisyphus.min.js works, but – like you said – localstorage doesn’t work for that field anymore.

    Did one of you already find a better solution for this? It looks like the set value for the dynamic field is visible in the source code, so there has to be a way to force this value to ‘the frontend’ of the field..

    Thank you in advance.

    Plugin Author B Hays

    (@benhays)

    Gravity Forms 1.9 introduced their own save and continue functionality, that may be of better use for you in this instance. https://www.gravityhelp.com/gravity-forms-v1-9-save-continue/

    I haven’t found any other alternatives to the solution aside from what’s mentioned above.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Dynamically populated field’ is closed to new replies.