fill out drupal webform automatically - php

How do I fill out my drupal webform automatically, I have 500 entries to fill out and I can't do it one by one. I try to fill it out automatically directly to phpmyadmin in drupal Database but it doesn't work beacause drupal add more fields in his database (in webform_ submitted_data) so I think it's possible to use a script or use a module to fill it out but I don't know how

The best module to do it, it's webform import very helpful
Allows delimited data files to be imported as submission (results) into webforms.
This is useful for importing submissions from other systems in to Webform. Can also be used to Edit submissions via Export / Import as long as the CSV has the SID column filled.

You can use drupal_form_submit() to submit a webform. See this answer over at drupal.stackexchange.com for instructions.
When you've got that working, it should just be a matter of looping over the webforms you want to fill in.

There is a sandbox module for that: Webform Autofill. But I 've never used it so I can be sure it works.
If you have never used a sandbox module you can see more details at the drupal sandbox modules documentation.

Related

Is there a way to execute a PDF field script while filling its form with pdftk?

I've been tasked to fill a pre-made PDF form via a Symfony app. I'm using this pdftk wrapper to do the job, but there's an issue.
This PDF uses some scripts for hiding/showing some field: for example, they trigger when a radio button has been selected.
When i fill the form with pdftk, the radio fields are changed correctly, but those scripts aren't executed, since those fields haven't been interacted by a human, i'm guessing.
I've already tried the flatten and need_appearances options to try to force their execution, but with no avail.
Is there a way to trigger these events from pdftk, or showing/hiding manually those fields, or there's an alternative to pdftk that does the trick? Keep in mind, i can't edit in any way the PDF, since it's an official document (in case you need it, this is the PDF)
Thank you!

Inisde prestashop create php/html BO page "secure". Module, token or?

I created two files, an html and a php.
The first contains a simple form that passes the data to the php page that has to process them.
They connect to the PrestaShop database to retrieve various statistical information.
Only that creating these two simple files are not "protected".
That is, anyone knowing the name of the files and the path could open them and run it anywhere.
I would like them to be "internal" to the back office of PrestaShop, "protected", in security to avoid external access.
I hope I explained myself.
What road should I follow? Module? Use tokens?
I inserted
include_once('../config/config.inc.php');
include_once('../config/settings.inc.php');
include_once('../classes/Cookie.php');
$cookie = new Cookie('psAdmin');
if(!$cookie->isLogged()){
echo ("Please login");
exit;
}
else{
echo ("Logged in as: ".$cookie->customer_lastname." ".$cookie-
>customer_firstname);
}
but it doesn't wors. I have white screen with "Please login"
It would be a lot easier to create this form as a Module, more details of how to do that:
https://devdocs.prestashop.com/1.7/modules/creation/
By creating it as a module you can control permissions per Employees and it's available only in back-office by default.
I suggest you to put form inside getContent method and process Form using postProcess method. More on form creation:
https://devdocs.prestashop.com/1.7/modules/creation/adding-configuration-page/
You can find many examples of this in native modules like ps_imageslider, ps_newproducts with simple one input form etc.

SilverStripe form pagination

I am using a form on a SilverStripe page, the form is currently quite long. I am looking for a way where I can paginate the form. I would like to have 5 fields showing. Once them fields are filled out the user could then click next and be shown the next 5 fields. Also a previous button would be required. Thanks for your help if you need any more info let me know.
You probably want to look into the multi-step-form module : "MultiForm is a SilverStripe module, allowing flow control for forms, and step process to be automatically determined based on configuration variables on each step class. It augments the existing Form class in SilverStripe."
I believe this allows you to do what you need. The github repository has a complete example to set up and I recommend reading it in detail.

Move form entries between Wordpress Gravity Forms

I have a tournament with multiple divisions and multiple forms for which I use gravity forms.
There are times when someone requests to be changed to a different division. However, I am unable to move the competitor from one division to another in gravity forms, as the divisions are each using a different form ID (and they have still not developed a method for helping with this).
How would I go about moving a SINGLE ENTRY from one gravity form to another forms entry list please.
We have many teams at the tournament, so mass export and import is not what i am looking to achieve. Its about being able to move a single entry from one list of entries in one form to another forms list of entries?
ANY help would be greatly appreciated. Even a simple "use this method" in general terms will help me greatly. Would I use some form of JQuery fiddle, a php script, an sql script or what please as Import Entries is not available currently in GF
Regards
You can not do that, but instead maybe you shold design your form to include all types of submissions logic. I mean you can put a drop-down field at the beginning of your form. Then you can use https://gravityview.co/ to edit your single entry field.
I have a workaround for this which i am using in one of my current projects for http://projects.dzign-r.com.au and that is,
1) export both of the the forms (i.e the one from which you need the field to move and the other to which you need this field to be moved to) and it exports these as json files
2) search for the field ID that you need to be moved to another form, cut its json code from the json file and paste it in the other form's json file where you need it to be moved to
3) then import the form back. and test it to make sure it works as you want it, (as a caution you may change the field ID after you paste it in new form to be something which is not used in this form already).
4) once u see everything is fine u may just delete the old form?

Adding action to Contact Form 7 submit w/ PHP hook

I'm having some trouble implementing a bit of custom functionality in the Contact Form 7 plugin for Wordpress.
What I want to do is pretty straightforward. The contact form in question is a normal contact inquiry form, so I need to retain the usual functionality (mailing the data). However I also have a checkbox on the form that allows the sender to choose whether to subscribe to the client's mailing list in addition to mailing the contact inquiry.
The client uses Bronto for their mass mailing (similar to CC or Mailchimp). Bronto has a "direct add" feature (more info here) that allows you to send parameters to add contacts to the Bronto account by embedding an image whose url contains the requisite parameters (email address, list to subscribe to, etc).
I can construct the image url with the contact form parameters no problem, but actually getting the image request sent is a different matter. I am over my head both in PHP and JS here and not sure what course to take.
Currently I'm using the wpcf7_before_send_mail php hook built into CF7 and this appears to allow me to collect the form data and build the URL. However, since the plugin uses AJAX and doesn't actually redirect to another page on form submission it seems I can't successfully use any kind of php output (echo, alert, even error_log), presumably because the server doesn't know what it's supposed to write to.
In functions.php:
add_action( 'wpcf7_before_send_mail', 'bronto_contact_add' );
function bronto_contact_add( $cf7 ) {
$emailcf = $cf7->posted_data['email'];
echo $emailcf;
}
This is just a test to see if echo works - it does not. Instead the form just hangs on submission and I see the rotating loading gif forever.
What I need to do is build the image url using parameters from the cf7 object (which I can do no problem) and then somehow send that image request to the Bronto server (this is the part I am confused about). If this was a normal form that redirected to another php page upon submission I would have no problem doing this at all, but it uses AJAX which I don't know much about so I'm pretty lost now.
Can anybody help shed some light on how the best way to accomplish this might be?
If the submit is hanging after you attached your function, at least you know that it had an effect. I'm not terribly familiar with Contact Forms 7, but this is probably not the proper place for an echo, and my guess is that it is hanging because you are writing to the buffer and then it is trying to do a redirect (check your error logs). If you want to see the contents of $cf7, a better way to do it would be:
// first option, using print_r()
error_log(print_r($cf7, true));
// second option, using var_dump() if you need the additional output
ob_start(); // start buffer capture
var_dump($cf7); // dump the values
$contents = ob_get_contents(); // put the buffer into a variable
ob_end_clean(); // end capture
error_log($contents); // log contents of $cf7
The contents of the $cf7 variable will then be in your PHP error log, which will tell you how to access the different components.
I came across your thread while looking for a similar solution to the same problem with CF7 - a hang on submission when trying to pass info to my own database on the back-end for a CRM.
I did not see an answer to this issue anywhere on the web in relation to CF7 integration, so thought I would post here what I found was the problem and how it was fixed. I'm no pro, but the solution works in testing, if anyone has anything to add to this solution please chime in
Basically, if you are using Wordpress and trying to pass the info into a CRM database, I am going to assume your database tables are not on the same database as your Wordpress site database. What you are then trying to do is establish two database connections simultaneously, but the reference ID is being reused for your Wordpress database when trying to connect to your CRM. I found this was the root cause of the hang on submission during testing.
I used a deprecated command from PHP 4 that still works in PHP 5, mysql_connect, :
mysql_connect('localhost', 'root', '', true);
By passing 'true' as your fourth parameter you are able to keep the connection separate from the one running for your Wordpress site. Did this and the CF7 submission doesn't hang, it submits to the CRM and sends it out as an e-mail simultaneously, no problem.
Note too though, if something is wrong with your syntax for the CRM data submission i.e. misnamed variable, etc.. it will also hang. If passing 'true' doesn't work check your code first to make sure it's clean.
If anyone reading this has an equivalent solution for this with 'mysqli' commands I'd be interested to know it, I tried it using mysqli and couldn't get it working.
Is there some reason why you can't just prefix the table names and add them to the same database? It seems that would be a better solution and would work fine with mysqli as opposed to using archaic, insecure drivers.....
I guess, I just don't see the point of using two databases in this case... I would try using one.

Categories