By fuzzbuzz on
I am Drupal 7.20. I want to use the webform module to create a webform with custom php embedded in it. On for submission I wanted to generated a custom page back to the user that would include some responses to the form. I could not get this to work with the webform module, so I created a seperate html form separate from the drupal site with embedded php.
My question is, how can I get this to work inside Drupal? Using Drupal webform module or as a seperate html page? I am a beginner in php programming and am currently taking a course on it.
Thanks in advance.
Comments
My question is, how can I get
If you have these two options, it's definitely the webform module. You will have to read into how to use hooks in Drupal. That's how you manipulate forms and add extra functionality.
I did see hooks come up in
I did see hooks come up in another forum. I will check it out and come back to update. Thank you.
hooks are tough
How do I know which hooks are associated with webforms? There are so many of them and I don't quite understand.
_
webform hooks will be described in the webform.api.php file.
But Webform may not be the best option. It's often not-- I see a lot of people gravitating to it (my guess is, based on the module name), when it's actually not the 'right' answer. You might be better off working with an entity or node form and customizing as desired. And optionally, depending on the details of the use case, you might be best off with a completely custom form api form.
If you provide more details about the actual use case (ie what you're trying to do, what type of info you are collecting, where does it go, who will use the form, etc), we can provide better assistance.
Types of forms
We have several forms. Many are them are to request user accounts or to request access to resources. We also use the webforms for voting and as daily checklists of todo's. I want to be able to display certain information back to users by html and to their email. I moved to Google forms, because I had a little more flexibility with this, but I want to keep data internal and take full control over our drupal website. The forms will need to be sent to a certain set of administrators and the person who completed the form. I will need to be able to keep track of this data. A few forms will also need to pull data from other databases.
The webform module itself seems to be good for basic form usage, but performing validation is limited as well as emailing form responses to the users and displaying a more customized page upon form submission.
_
Unless you're collecting data for usage primarily outside the drupal site, webform isn't really the best answer. It's meant to be a data collection method for non-site data to be sent elsewhere. Much like a questionnaire or survey. Personally, I wouldn't use for any of the items you describe. I would likely use nodes for much, if not all of it, with perhaps a custom entity.
And I primarily use rules for sending emails with mimemail but sometimes also mass_contact, newsletter, or simplenews depending on the type of mailing I need to do.
I thought a webform was a
I thought a webform was a type of node.
Webform just attaches itself
Webform just attaches itself to a node to have a URL path, some optional additionial content and a way to reach it's administration interface.
Technically it doesn't have to du much with the node. It has it's own data structure, which is quite hard to access if you want to do anything else than displaying or maybe exporting it.
So here I must agree to WorldFallz, that a tailormade form is probably better, as you're completely in control of the data and can save it and then access it however you want, eg as nodes or whatever.
OK. So I will follow
OK. So I will follow WorldFallz advice below, to the best of my ability.
"You might be better off working with an entity or node form and customizing as desired. And optionally, depending on the details of the use case, you might be best off with a completely custom form api form."
Node form and custom form api form are new to me. I am inexperience so I will have to research. I will feel really accomplished if I can get this to work. It has been a goal of mines for the past year.
Thanks.
_
A 'node form' is simply the form api form you get 'for free' whenever you create a content type (entity bundle). You can pretty much alter it any way you might need with hook_form_alter and custom submit and/or validation handlers. If you can use a core content type for your data, then you can just alter the form to collect it as required.
If however, you want complete control over the data or don't want to use nodes for whatever reason, you can use drupal entities to structure the data however you want as well as create the form. The advantages of this method are 1) you get to leverage drupal to do a lot of the heavy lifting for you (CRUD) and 2) you get views, and many other contrib module, integration for free.
The last option, completely custom code for page callback and data storage outside of drupal, is the most work and requires you to write all the code yourself. Personally, I've never needed to do this. I always use either customized nodes or custom entities.
I do not have time for
I do not have time for extensive custom coding. My level of expertise is not good at this moment. It is so much to learn and do with Drupal that my head can explode.
I have somewhat succeeded in making the site performance better. So, now I can focus more on hooks and creating the form that is going to work for me.
This form will collect unique info that actually comes from another database outside of drupal. That will need to be stored so that it can be viewed later if necessary. I don't have any requirements for where that data must be stored, but I am looking for the most easiest way, which I think will be somehow within drupal. That info will include what is pick up from the database outside of Drupal as well as the date and time that the info was recorded.
_
Now I'm really confused. If the data exists elsewhere-- why does it need to be a form at all? Are they going to modify it or just display it?
Aside from that however, based on this additional info, I would definitely just use a node/content type and modify the form as necessary with hook_form_alter. That's probably the simplest, easiest, and least code heavy method. And there's tons of info customizing node forms with hook_form_alter.
The information will be
The information will be displayed. It will not be modified at all. The drupal site is the main place for all forms user will use so that is why I am trying to integrate in to Drupal. The drupal site is like one location for everything. The form will generate a list, sort of like how a payroll department uses an attendance management system, except my form will not do any further processing of the data other than displaying it and logging it to view at a later time if needed.
I can get the ball rolling on hook_form_alter. It's really helpful that you narrowed it down for me, because it is so much to learn with Drupal. I am learning as the need for knowledge arises, because I work fulltime and managing the site is not yet my fulltime assignment. I can't wait until it is.
_
Then I don't understand why you need a form at all. And if you don't need a form, you don't need hook_form_alter.
Simply set up a content type to house the data, use feeds to import the data, and don't give any roles permission to create or edit the content type. Then use views, panels, and/or display suite to display it however you want. I do this all the time for external data sources, and it works brilliantly.
I may not be communicating my
I may not be communicating my intentions well.
I only considered webforms, because I wanted to have a single input field that would take an ID, search for that ID in an external database and then log that ID, the name attached to the ID, and the time their ID was scanned. This log will be created and stored within Drupal. It would be similar to a clock-in clock-out system that an employer will use. It will log info based on a ID.
I saw some attempts to create something similar with a Drupal Course module or Sign Up module. I can't risk using these modules that someone has done, but have not kept up with. So, I am trying to do it myself with limited expertise :-(, but with the Drupal community support :-). I know that there must be others out there still trying to get something like this integrated into their Drupal sites. So, I will repost this as another thread, since as you stated, webforms may not be the way to go.
_
I wouldn't recommend starting a new separate thread unless the question is completely different--- you'll lose the context and what has already been discussed and may well waste precious volunteer time rehashing what's already be brought out here.
If it truly is a new question, you may at least want to link this thread so as not to lose the context.
That's the best explanation of what you're trying to do yet. Based on that information, you definitely shouldn't be using webform. The course and signup modules won't do this either so there's no point in trying to use them regardless of their status.
Unfortunately, this is squarely in the realm of custom code. If you can't do it yourself, then you should probably consider hiring someone who can.