How to create a custom module from Webforms in Drupal 7 - 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);
}

Related

Cakephp3 handle authorization as a plugin

I've been working on cakephp3 for a while now. I've always used Cakephp's Auth component for authorization and authentication purpose.
I follow the very conventional procedure every time, like loading the component, adding isAuthorized function in controllers and defining allowMethods etc.
But now what I want is to develop my own plugin for this purpose, just using Cake's Auth component. So that i can reuse the plugin in all my future projects, also i want it to be like plug and play. Like You enable it, add few settings and your User management is done.
I know that how migrations work so I can add users table via migration every time. (Just an idea)
The thing I don't get right now is how to make everything separate from the core app? Like everything is done via plugin and nothing is added to every controller of the app.
Hope I'm clear about what I want to achieve.
Update: I know there is a whole list of third party Auth plugins. But I want to develop my own so i just need the idea of how things work.
Any solutions to my problem would save my day.

Drupal Webform values before submit

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.

Cake PHP Form Flexibilty

I want to replicate the html that the cakephp form helper creates, so i can add to it and integrate it into my bootstrap front end. Basically the cakephp form helper isnt generating the html I need.
Someone else built the app using cake forms, and I dont want to rewrite the backend.
I thought it would simply be a case of including the correct input names, form classes etc, and building upon it. It seems however that even an exact copy/paste of the form html doesnt trigger the cakephp form errors.
It sends identical headers to cake,
http://pastebin.com/JZyCk6cv
so I can only assume that the cakephp form helper does some jiggery pokery when its constructed in the template, in order to trigger validation errors?
I think the best solution is to create a custom CakePHP-Helper. If you're using twitter-bootstrap i recommend this Helper, packed as a plugin:
https://github.com/loadsys/twitter-bootstrap-helper
Form validation should work, as it uses CakePHP's core form-helper to create inputs and labels.
Maybe you don't have to rewrite or edit much if you use search and replace (replace $this->Form->input by $this->TwitterBootstrap->input).

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.

CakePHP 2 - single core, two apps, one inside the other?

I'm fairly new to CakePHP and am trying to setup a custom admin area for my app. I realize Cake can create an admin area with scaffolding but I'd like to build something much more customized, and have it accessible from via /admin/, with one app for the public side and another for the admin.
Ideally, the structure would be:
www
^- apples (public application here)
^- apples-admin (password-protected control panel)
I'm having a hard time figuring out how to set this up using a single Cake core and two apps - one for "apples" and one for "apples-admin". I've read some notes about modding PHP's include path, but that won't be possible in the production environment. The other notes I see about changing CAKE_CORE_INCLUDE_PATH aren't very clear on where I would make that change, and it doesn't appear as though that would get me the app-inside-app structure I'm after.
Is what I'm trying to do possible? Am I better off using just a single app for both the public side and admin area?
You can achieve what you want using a single application.
To get up and running:
Use Prefix Routing to map your admin actions.
Then use the Auth component to restrict access to your 'admin' actions. I recommend setting up a User model to manage your users and using the FormAuthentication handler for logging in.
If you haven't used Bake for code generation before, then that's also worth looking into. It'll help create a base starting point for a lot of your admin functions.
Good luck.

Resources