Add custom form data to Drupal module without using CCK fields - drupal

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.

Related

Create moderation for form data

I want to add moderation logic for a form which has name, mail and comment. Now when anyone fills the form and clicks "submit" it should directly be posted to the page. I want to send the content to "admin" and to be published after the content is reviewed. How can I achieve this in Drupal? I'm using Drupal 7.2.
There are many ways to achieve what you want. I guess you are looking for a site-builder approach.
Then you may have a look at the Webform module. Webform lets you build forms and define e-mail addresses to where the submitted data should be send to.
Then there is the Rules module with which you can define a rule that on every form submission automatically a (initially unpublished) node is being created populated with the form values.
And finally you may provide a list of all unpublished nodes built with Views. Maybe you already provide a button "publish" next to each node in the list that triggers the node publication.
Alternatively you may also have a look at moderation modules like Workbench Moderation.
Or have a look at the Flag module which is pretty useful for flagging content according some logic and/or button clicks. For example you can add a flag: approved.

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.

How to create a custom form in 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

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.

Drupal CCK Field Level Visibility

I am using the Drupal 6 module Content Profile to allow using a CCK defined type as a user profile which is working well. The issue I have is that I want the first completion of the profile to trigger an action however the user may save the profile without completing it. My thoughts on this is to have a checkbox by the save button which states 'My profile is complete' which the user will select once they are happy with it, and I have another module which creates a trigger by using the node_api hook and checking the type of the node, the action, and the value of this checkbox.
Once this trigger has been raised I don't want that checkbox to appear again however. If I could set the visibility of the checkbox using PHP code that would work as I could write a short script to determine if the completed action has already happenede and if so hide the checkbox. Is there a module that allows this? I haven't been able to find one.
I have also looked at using the same node_api hook to manipulate the profile as it is being displayed however the node just seems to have the values for the fields and not a form object that can be manipulated as I would have expected. IS there a way to programatically manipulate a CCK form?
Thanks
I think hook form alter is what you are after. This can perform alterations to a form before it is rendered.
I would suggest another approach using the Save & Edit module. Set your CCK profile type as "unpublished" by default. Allow users to save it and/or save AND publish it with this module. On publish, use triggers and actions.
This approach is arguably more in keeping with the Drupal way - configuration over customization.

Resources