PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Next and Previous Button class change

  1. clarkson
    Member

    Hello, i was able to change the submit button class by adding this code to my theme's function file

    add_filter("gform_submit_button", "form_submit_button", 10, 2);
    // filter the Gravity Forms button type
    add_filter("gform_submit_button", "form_submit_button", 10, 2);
    function form_submit_button($button, $form){
        return "<button class='fancy_button' id='form_submit_button_{$form["id"]}'><span>Continue to Payment</span></button>";

    but when i tried to do the same for the Next and Previous buttons, [Multi Page buttons ] it didnt work,
    here is the code i used,

    add_filter("gform_next_button", "form_next_button", 10, 2);
    add_filter("gform_previous_button", "form_previous_button", 10, 2);
    // filter the Gravity Forms button type
    add_filter("gform_next_button", "gform_next_button", 10, 2);
    function form_next_button($button, $form){
        return "<button class='fancy_button' id='form_next_button_{$form["id"]}'><span>Next</span></button>";
    }
    // filter the Gravity Forms button type
    add_filter("gform_previous_button", "gform_previous_button", 10, 2);
    function form_previous_button($button, $form){
        return "<button class='fancy_button' id='form_previous_button_{$form["id"]}'><span>Previous</span></button>";

    Help me :)

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  2. There isn't a filter for the previous and next buttons at this point. That's why your code isn't working.

    You'll have to either change the button styles with CSS or use jQuery to append/change the class name for now.

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  3. clarkson
    Member

    could u give me more information on how to use jQuery to append/change the class name for now.
    like where to start

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  4. Something like this..

    <script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function($) {
    
       $(".gform_previous_button").addClass("newPreviousClassName");
       $(".gform_next_button").addClass("newNextClassName");
    
    });
    </script>

    http://api.jquery.com/addClass/

    http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  5. clarkson
    Member

    Kevin,
    im kinda noob with codes stuff,
    could u tell me where to insert the code you just pasted please?
    regards

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  6. Yeah, check that last link I posted. The info you need is in there. You're probably going to want to put in your header.php file or else in a separate page template you create and use for your form pages.

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  7. clarkson
    Member

    Hey Kevin,
    i insterted this into my header.php file

    <script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function($) {
    
       $(".gform_previous_button").addClass("fancy_button");
       $(".gform_next_button").addClass("fancy_button");
    
    });
    </script>

    it worked on the first page, but when u press next, the next 2 buttons is still the same :/
    take a look here
    https://psdtowebsite.net/order
    im confused

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  8. clarkson
    Member

    I Managed to fix it by modifying [form_display.php] file

    Line:1392 "button gform_next_button"
    Line:1393 "button gform_previous_button"

    change them to whatever class u want :)
    thx

    Posted 13 years ago on Thursday September 22, 2011 | Permalink
  9. Sure, you can do that but you'll have to remember to update that core file every time you upgrade the plugin. That's not something we recommend doing.

    Is there some reason you can't simply style the buttons using the existing class name? That would be a lot easier and you don't have to continue to hack core files.

    Posted 13 years ago on Thursday September 22, 2011 | Permalink