I'm new to Drupal 7 and installed it on my local machine to play around.

I'd like to build a basic Job Posting Form and wanted to ask about questions/best practices regarding Drupal.

This was the process I was going to follow:

  1. Create a new content-type "job", add a title, description and pay - all text fields.
  2. Create a new module, then within the module build out the custom form to create a new job listing. How do I associate the new form with the content-type? Should I build the form code in my custom theme folder (template.php) or in a new module?
  3. When the form is submitted, how does the data get saved? How do I associate the submitted form with the database? Most of the examples using the Form API only mention building the form but not how to store the data (in my example, storing the "job" as new content).

I'm not asking for you to write code for me, but I'm having a difficult time understanding the workflow and best practices for working with Forms in Drupal 7. Any good guides on how to accomplish what I need would also be appreciated.


Great to know you're exploring Drupal! :D

Create a new content-type "job", add a title, description and pay - all text fields.

Since you want to ask data from users or something like a survey, Geek Alvaro J Hurtado V is right. The Entityform module is the way do go since it uses entities and fields which are future proof and used in Drupal 8.

Brings me to another module called Views, Entityform works well together with the Views module. This module helps to create data lists without any coding needed. This is one of the most used module in the Drupal world. Check it out if you have time. :)

How do I associate the new form with the content-type?

When the form is submitted, how does the data get saved? How do I associate the submitted form with the database?

The Entityform module already handles this for you out of the box.

So what you need to do is to create your survey form using the Entityform module and you're basically good to go. You would have:

  1. A public form where your anonymous/not logged in users can fill-up.
  2. A content type where it relates the data submitted by the user.
  3. A page which lists all the user submitted data.

Jobs will likely be included in content listings on the website. a "job form" should just be a content type. While frowned upon in general this content type could be given Anonymous User access to create new content.

Drupal handles storing content type data for you. Now you just need to likely work with that data. Look at using Rules or Drupal Hooks to store the newly created (and or approved/vetted -- you can approve Node content with many modules, 1 of which is Workbench) job entries in a Queue (using Rules Queue) for additional processing during Cron run.

Using the Features module -- you can do 99% of the above configuration and business logic in your website as an Administrator and then export this configuration and business logic to code in a Feature.


sorry frowned is a poor choice of words. Anyway you cut it people are submitting content to your website (job postings) that type of stuff should be audited somehow (right? Viagra posts anyone?).

I'm suggesting this route because you could try hand coding stuff, and you'd be re-creating all or some of the modules i mention here. There are security concerns giving anonymous users access to create content, such as you'd only want to give them access to Filtered HTML as an input type -- if you don't understand the possible dangers then it's frowned upon to be playing with fire.

  • Given that what you described is generally frowned upon, what method "should" be done to do it more effectively? For example, what if my form was significantly more advanced, what approach should I take in that case? I was hoping to understand how to use Drupal without necessarily installing a bunch of custom modules, but maybe that's the best approach is to just install a bunch of module and not mess with any code...
    – ews2001
    Jul 25 '14 at 20:25
  • see my edit plz
    – tenken
    Jul 25 '14 at 20:33
  • In general your asking about Forms. The FormAPI in Drupal is for any type of Form. But Drupal provides many forms for you out of the box. Such as to create Content Types, Contact Page forms, User profile pages, possibly "webforms" which store data exportable to CSV. It's not advisable to try to create your own forms that replace drupal built-in components such as content forms via a Content Types as I've outlined here. Make sense? So try to look through core/community for a suite of modules that fit your needs which your custom modules can hook into and adapt to your needs.
    – tenken
    Jul 25 '14 at 20:43

If you build simple form the best is to create content-types, install couple standard module and do job.

Good module for the form is WebForm Module

If you have a complicated forms the best is to custom build form and you have module with example how to do that Examples for Developers

I hope I helped you.

  • So, how can I associate a content-type with a custom form in my module? I'd like to create a content-type, then build a wizard form to collect a form based on the content-type. Do I use the WebForm module for that?
    – ews2001
    Jul 30 '14 at 14:44
  • One solution is to create own entity types with module entityreference here is the good how trellon.com/content/blog/creating-own-entities-entity-apito page
    – mlivan
    Aug 11 '14 at 11:54

In this case, I think the best option is entityforms.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.