How to create a custom form in drupal - drupal

I need help on how to create a 'custom form' using the same fields provided by cck.
Drupal gives you the ability to add fields to 'nodes' and how to theme their output. But I would like to be able to post a data from my own form (that pops-up) and sends data to the drupal database using the same drupal cck.
How do I access the specific form inputs to add data to my content types ? because the default form is kind of 'ugly' and loads on different page(without ajax).
Help would be much appreciated

There are several routes you could go down.
The easier option is to use the Webforms module. While this gives you similar fields to cck, they are not exactly the same, and if you have a module that implements a specific cck field type, it won't be available to webforms.
The second choice is to write your own module using the forms api. This can mean a lot of learning, add it takes time to get up to speed, but ultimately you have total control over how your form will look and behave. The forms api doesn't give you exactly the same fields, but all the tools are there to create them. Sometimes you need to hack open a module to find out haw a specific field is implemented.
A third option would be to use cck itself. You could create a content type and add the field types you want on your form. You would them give users permission to create but not view or edit the content type. The form submissions would them be nodes on your website. This would make me slightly nervous, so make sure all your permissions are correct!
The second part of your question: you can use a theme file to override the appearance of most forms and make them pretty.
James

Related

Add custom form data to Drupal module without using CCK fields

Iam very new to Drupal 7 so bear with me. I have created a jQueryUI drag and drop interface with JQueryUI tabs. My problem is i cant find the correct hook to add this custom interface to the admin interface. Like so (mockup) http://onlinemedia.rmcad.edu/sandBox/screenshot/screen-shot.jpg
All the examples I find are using CCK fields. CCK fields are great but they dont have this kind of custom functionality I want or does it?
Any help would very much be appreciated.
J
cck is drupal 6, not 7. to add to the node creation form you could use hook_form_alter or hook_form_ID_alter.
Check the form api documentation to get an idea of how to add stuff to the form object in either of those hooks.
From your mockup I understand you intend to add this drag&drop interface to a content-type.
If that's the case, I'd recommend you to add the appropriate fields first. Those would help storing the data in Drupal way, once the node is saved.
Once you are satisfied with the fields collecting the data you need, create a module and use hook_form_FORM_ID_alter hook to integrate your "interface", the presentation layer by altering those fields.
If you don't want to add CCK/Field components to store your data how about you create your own database table and store your custom data in there?
This approach is a long one but I have used it to great effect on a very big and complex project.
You will need a custom module with an install script which contains the details of your custom database table.
Forgive me but I don't remember the hook for altering a node-edit-form but that is where you input the code which implement your drag-'n'-drop elements.
Then, you could save the settings altogether when the node-edit form is submitted but I think it's probably better to implement some AJAX to save the settings to your custom database table. So, when a component is dropped into it's final resting place, you use AJAX to save that information to the database.
When a user comes back to edit that page, you simply load your custom settings and apply them to the drag-'n'-drop features and their previous configuration(s) would be visible to them.
I do hope that makes sense and it helps you.

Exporting a specific user's content from Drupal 6

I am new to Drupal. I am working with a preexisting website that has a couple dozen staff bloggers. Some of the bloggers need to have all of their posts migrated out to a database (the CMS they will be imported to is not yet known).
I have looked into a few modules for backups, but they don't seem to have the ability to choose what exactly is exported.
If anyone could give me some advice or direct me to an appropriate module, that would be fantastic!
You can do it easily with Views and Views Data Export modules.
However, you will need to learn a little about Views before making use of the Data Export module. You can follow some quick tutorials. You will not need any coding skills but concentrate on Views UI , Filters and Arguments.
Make a View on node as primary content, and add a filter (or an argument if you want to take the user ID from URL) for User: UID and add fields you want to get exposed as Fields. Then, in the style settings, choose "Data Export". Create a page display and give it a path.
You can also make the form advanced with exposed filters.

Client management page on Drupal 7

I would like to know what is the best way to create a custom page for my client where he can update is content by himself, the simpliest way possible for him, without even entering drupal management.
I would like to create a page with different dropdown list where he can't update a table on a page, only by selecting an item in those and add other dropdown list as well.
For example: he logs in a custom page
Theres a list with different kind of fruits, he choose banana and it automaticaly update a page table and update it with banana.
After that he could also create a new drop down list of vegetables for example, and add different kind in it so he can use it to update the site later. All that done with ajax as well.
I'm very new to drupal and have a couple of php notions, but i don't know where to start, would it be in CCK, Views or Form Api or the three at the same time?
Or is there a module out there doing that kind of thing?
English is not my primary language, so sorry if it isn't very clear.
Thank you very much.
I think what you are looking for is CCK module. You can create a CCK content type and have a field within it called fruits. From the admin interface you can decide what are the values that should be in the dropdown.
You can give the client permission to create a node of the content type. If you think he should be able to edit only the drop down values, make sure you give him the permission to only that field.
You can create a listing page using http://drupal.org/project/views or you can also consider using
http://drupal.org/project/editview
You should take a look at views bulk operations, and try using the "modify node fields" feature which will allow you to perform bulk operations on node fields displayed in a view and then look into roles & permissions which will help you restrict viewing the "View" by role.

drupal6 taxonomy cache, dropdown arrays & webform vs cck questions

1.is taxonomy do caching ? i do a form that user needs to fill his personal infomation and that include a street name, i wonder how to do it, in taxonomy or in cck text field... what is better?
what is the best way to do a form dropdown options of known-non changing options? like choose color:
red,green,blue.orange,gray ... should i use function and call to array? variable_set/get()? taxonomy vocab?
if i do a form for user that will not send to email its just need to add a node or stuff like that, is webform is a better alternative to the cck module?
taxonomy does no caching afaik. To have adress etc info for user i 'd use profile module in core. (you use d6 or d7?) ,
to 1. simple list of non-chaning option which does not need to maintained elsewhere (db/file) you use cck text field and provide values to choose from. Of course for many values, a cck taxonomy field is nice , because there are good import modules (taxonomy_csv and _xml)
question 2 i find hard to understand, pls elaborate a bit
Taxonomy isn't cached. It is also not really the best choice for entering addresses, CCK is perfect for that. If this data isn't going to be content Webform is ever perfecter :)
The benefit of Core+CCK for form based data collection is you can make nodes out of it, which means you can do anything that you would do with a node to the data you collect. Query, Display, Rules on it, whatever.
The advantage to Webform...is that that it's not turned into a node, as such it's more specialized for collection of information such as surveys, questionnaires, contact forms, etc and there are plenty of integration modules for webform to help you see/use your data in cool ways.
Re your questions:
1) CCK Text/Select - OR - the equivalent in Webform
2) Core & CCK, you cannot add site content with Webform
Cheers

Is there a customizable form in drupal similar to the contact form?

I need a form to enable user to enter event info in three fields (what, where, and when). Then I would like to be able to present the events in tabular form. I don't know PHP. Does drupal have a module for this purpose?
The content construction kit (CCK) allows you to create content types with custom fields, and automatically produces the forms for those content types. You'll probably also want the date field for the when.
You would use Views to display data as a table.
http://www.drupal.org/project/views
Drupal Form Builder
Will create quick forms for you on the go.
Drupal CCK
This one is a little bit more envolved, but more definitive, common place, and HIGHLY extensible. Here's a nice little tutorial as well.
If you don't want the results (events) to turn into nodes when the user enters the data and submit the form, then you should look into the webform module.
A while back I "demoed" this to my peers by building a "mcdonald's monopoly" tracker that anyone could use to input their pieces and then I setup a view as a block to display the aggregate result for everyone's pieces.
We didn't win anything, but this may be what you are looking for.

Resources