Coder Social home page Coder Social logo

gravityhelper's Introduction

Gravity Helper

GravityHelper is a simple library that provides an easy way to do common tasks related to Gravity Forms.

Installation
  1. Clone the repo or download as a zip
  2. Include gravityhelper.php in your theme or plugin
Basic Usage
use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper();

This will initialize the object for all the forms (globally). If you need to target a specific form, provide its ID in the parenthesis.

Available Methods

ajax_spinner() - changes the image of the spinner when used for an AJAX form.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper();
$GravityHelper->ajax_spinner( get_bloginfo( 'stylesheet_directory' ) . '/images/ajax-loader.gif' );

button_submit() - turns the submit button to a <button> instead of an <input type="submit">

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper();
$GravityHelper->button_submit();

button_atts() - specifies the attributes of the button when used with the above method.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper();
$GravityHelper->button_submit()->button_atts( array( 'class' => 'btn btn-primary' ) );

button_content() - specifies the button content.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper();
$GravityHelper->button_submit()->button_content( '<span>{content}</span>' );

NB: You can use {content} as a placeholder for the current content of the button.


get_entries() - gets the form entries. Equal to GFFormsModel::get_leads(), requires form ID.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper( 1 );
$form_entries  = $GravityHelper->get_entries();

get_fields() - gets the form fields. Equal to GFFormsModel::get_form_meta(), requires form ID.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper( 1 );
$form_fields   = $GravityHelper->get_fields();

get_entries_data() - gets an associative array with the fields as keys and entries as value.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper( 1 );
$entries_data  = $GravityHelper->get_entries_data();

switch_to_form() and reset_form() - switches or resets the current form to global. Useful for chaining.

use GravityHelper\GravityHelper;

$GravityHelper = new GravityHelper();
$GravityHelper
->ajax_spinner( get_bloginfo( 'stylesheet_directory' ) . '/images/ajax-loader.gif' )
->button_submit()
->switch_to_form( 1 )
->button_atts( array( 'class' => 'btn btn-primary' ) )
->reset_form()
->button_content( '<span>{content}</span>' );

gravityhelper's People

Contributors

kaloyan-dev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.