Search code examples
phpgravity-forms-plugin

Gravity Forms - Custom submissions?


I don't want to use the output that Gravity Forms has and would like to create my own form, but still use its back-end for entries, the field creations, etc..

I can do everything so far but the entry submission. I've looked and looked, without any luck. Is there a way to create an entry in Gravity Forms? Some class function?


Solution

  • So the only way to get this done is to create a placeholder page, embed the form, and then use JavaScript to create an iframe and submit the form within.

    Some sample code:

    app.controller 'SubmitForm', ['$scope', '$timeout', '$filter', ($scope, $timeout, $filter) ->
        $scope.data = {}
        $scope.loading = $scope.thanks = false
    
        $scope.submit = ->
            $scope.loading = true
    
            $frame = $('<iframe/>', {
                id: '#dynamicGF'
                src: "/form-placeholder-page/?#{$filter('obj2url')($scope.data)}"
    
                load: ->
                    $frame.contents().find('form [type=submit]:first').click()
    
                    $timeout ->
                        $scope.$apply ->
                            $scope.loading = false
                            $scope.thanks = true
    
                        $frame.remove()
                    , 175
            });
    
            $frame.css
                width: 0
                height: 0
                visibility: 'hidden'
    
            $frame.appendTo $('body')
            @
    ]