#1 October 20, 2016 10:53am

tsamant
Member
From: Chicago
Registered: May 14, 2015
Posts: 52

Extending FormBuilder

I am thinking of a side project involving FormBuilder, but not sure how to organize it.

The aim is to produce a json export of form submissions, given a date range. In the ideal scenario, the form in question would be located via the page it is included in.

Much of this code is ready in command-line form. But what is the right place to install it? Would I have to patch FormBuilder, or should I make a custom class?

Related questions:

What would be a good URL for this sort of endpoint? E.g. for http://example.com/admin/pages/edit/1/ it would be nice to have a predictable json URL.

Is there a way to log in to admin from the command line? It would be great to script this sort of thing with e.g. curl.

Best,
Tushar

Offline

#2 October 20, 2016 10:57am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: Extending FormBuilder

I'd probably not extend Form Builder directly since it could possibly be overwritten by a future Form Builder extension update. I'd add a new module or just some scripts in /custom/admin/ajax/.

Unfortunately there's no way to use the default authentication over the command line so if that's a requirement you'll probably want to put the scripts in /templates/ajax/ instead and use a secret key for authentication over the command line.

Offline

#3 October 20, 2016 2:45pm

tsamant
Member
From: Chicago
Registered: May 14, 2015
Posts: 52

Re: Extending FormBuilder

Thanks!

By secret key (for the templates/ajax way), do you mean an ssh key? Or logic in the script to check a key?

Offline

#4 October 20, 2016 2:47pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 978

Re: Extending FormBuilder

Just logic in the script - an example would be generating a 32 character random string that only your command line and the AJAX script know. You could also add additional security by checking if it's being run by command line, e.g.

if (PHP_SAPI !== "cli") {
    die("Must be called via terminal or cron.");
}

Offline

#5 October 20, 2016 5:06pm

tsamant
Member
From: Chicago
Registered: May 14, 2015
Posts: 52

Re: Extending FormBuilder

Sounds great, thank you! Tushar

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.