Drupal Webform values before submit - drupal-7

I'm using Drupal 7, Webform 3.19 and CiviCRM 4.3.
I am using webforms to update CiviCRM information. What I'm trying to do know is to send an email after a webform has been submitted with the values after submit and values before submit, to notify the change done.
Is this possible? I've also been looking at Rules and I have found nothing...
Thx

The short answer is that you'll need to write a custom Drupal module or CiviCRM extension.
It would use hook_civicrm_pre and would have to distinguish between updates coming from your webform and updates coming from normal backend work. There may be some other hook for Webform that is called pre-saving that you could use for that. (hook_form_alter would allow you to add something to process pre-saving, but there's no sure way to know that you're getting the same contact ID as Webform does). Regardless, your module/extension would need to retrieve the relevant fields from the existing content and email it to you along with the form values.
You could alternatively enable CiviCRM's logging feature, but this will often cause problems with database bloat and upgrade headaches. (Which is why it's labeled as a beta feature years after it was introduced.)
A final option could be to only send this when there are defaults provided (i.e. only if someone is logged-in or using the checksum). There, you'd still need to write a custom module, but it could be more reliable in pulling the right contact's information.

Related

How to Add Records to 2sxc data from DNNSharp's Action Form

We have DNN Sharp's Action Form being used by client-partners to post new job listings. The Locations and Categories for these jobs are managed in a little 2sxc apps. We want to extend the ActionForm a little so that the user has the ability to add a new Location or Category when they post the job listing.
What method/action would I use in Action Form to be able to add a record to Locations or Categories data which are both inside the 2sxc App?
At the moment there is no quick way, because there is no adapter. You could create some manual code or create an adapter - but that's probably a day or so of work since you probably don't know the Action-Form APIs for all that.
But if you do do it, please share :)
I had a similar project. I wanted a form configuration tool for commonly used forms so that a staff person could fill out date, price etc. without getting under the hood.
I kludged it together using
var formFields;//Angular Controller For Form Fields
formFields = getScope('ActionFormCtrl').form.fields;
Then shoved in my 2SXC values
formFields.EventDate = "#Content.SessionDates";
formFields.$digest();
This is definitely not the angular way but it does work. Note that you need to run the JS after the form is rendered.

How to create a custom module from Webforms in Drupal 7

I have a form that I am aiming to submit to paypal payment.
I have tried several options like the Paypal API and the like but I can't seem to get the hang of it since the requirement of what I am doing is pretty simple.
Right now I have a form and I am using Webforms to build it. I am well aware that webforms has its default value for action attribute which is not so easy to alter.
Also, the names for the inputs appear to be something like:
name="submitted[last_name]"
To be direct, I would like to change the actions url of the webform and then the field names from to simply name="last_name"
Is there a simple way to do it? If there is, I would appreciate your suggestion.
Also, if what I assume based on my reading that it is not possible, I have read in this question (Using Hook_form_alter on webform submitted values) that I can create a custom module based on webform and make the changes there. The problem is that I am new to drupal and I am still trying to understand how to make things work and I have no idea how to start or create the custom module based on webforms. Is it just simply copying the whole files in webforms then replace all occurences of webforms to my custom module name?
You dont create a module from webforms, instead the usual practice is to hook in to specific form from another module.
Basicly you need 1 folder and 2 files in there, eg mymodule folder and mymodule.info + mymodule.module . Good place to place those would be sites/all/modules/custom/ under your installation directory.
Read the description about .info file at https://www.drupal.org/node/542202
You can connect to webforms in many ways but the standard way in most form tampering cases start with hook_form_alter. Your module could start with something like this
<?php
function mymodule_form_alter(&$form, &$form_state, $form_id){
/* find and tamper with $form here
install devel and then uncomment the following */
//dpm($form);
}

Drupal webform submission creating new table

I have created a webform. However I want that whenever I create a new webform and if I input some data and submit it, It must create new table in phpmyadmin for every new form that I create.
By default every submitted data goes to "webform_submitted_data" table. I want every webform that I create must have separate table.
Please give me steps on how to do that.
If you use the webform module as is, it will use its own database table structure exactly as you describe.
If you have particular requirements on how the data of your webforms is stored in the backend, you'll have to create your own custom module that either builds its own forms and does the data storing itself or that hooks into the existing webform functionality and changes just the storing and retrieving part of it.
In either case, it'll be a bit of work on your part to build that custom module.
How the data is stored isn't something you can just configure for the webform module... :-)
However, I'm not sure why you want to change the way the data is stored, but you're aware that you can export the submissions data as csv and other file formats to manipulate later, right?
The webforms mysql view module will give you a pseudo-table for each webform, allowing read access to the data.

CakePHP Ajax form - cloning form fields

Using cake 2.2. I currently have a form (built using the form helper) that allows users to add expense claims. Each claim consists of many expenses. So the form contains a row for each expense along with a button that uses jQuery to clone the first row of fields and insert them (with incremented ids/names). The problem is when the form is submitted and there is an error, the cloned fields disappears as the page refreshes (I guess because their not in the dom any more).
The values are still in $this->data so I guess I could manually rebuild them but if I made the form submit by ajax would it solve the problem? IE on error the cloned fields would still remain?
Thanks in advance
Things that are built from Javascript will not retain from one page-load to the next.
Either use Ajax (probably ideal), or build out the fields with PHP based on the supplied data.
Either way is fairly "normal" way of doing it.

DotNetNuke -- Inserting URL parameters in forms

We are migrating our website to DotNetNuke and are looking to replicate the functionality of our survey page. Currently, on the bottom of every e-mail we send through our CRM system, there is a link to a satisfaction survey along with some parameters to pre-populate some of the fields. So the URL looks something like like:
/survey.aspx?ticketID=1234&userName=John+Doe
I found the custom module "helferlein_Form" which seems okay for actually creating the form that the user fills in, but I don't see a way to pre-populate the fields. DotNetNuke does let you insert tokens(ex: [Date:now], [User:username]), but I don't see a way to grab individual parameters from the URL. Is there something I'm missing that will let me do that?
I'm not familiar with that module either, but I would strongly recommend using Xmod for customized forms that allow you to easily grab url parameters.
I'm not sure about the module you reference.
However, in my experience Dynamic Forms from Data Springs would fit the bill perfect. It has the ability to pre-fill and even run custom SQL queries to get data.
You should definitely try our My Tokens module.
It allows you to access the URL parameters using [Get:ticketID] or [QueryString:tickedID]. You can also build SQL tokens that use these parameters to return a list of items for example to populate a dropdown.
Also try our Action Form module which integrates very nice with My Tokens.
If you have a module you like and want to use you can always write a little javascript to grab the variables out of the URL and pre-populate your form fields using javascript.

Resources