drupal-forms

Create multiple CCK nodes with single custom form in Drupal

拜拜、爱过 提交于 2020-01-13 19:12:07
问题 I need a form which will allow creation of several related nodes at the same time. All of the nodes involve CCK fields. I would like to use as much of CCK's built-in validation, submission, input widget, and security functionality as possible/practical. What is the best way to accomplish this in Drupal 6? Are there 'best practices' or docs anywhere? Here are 3 possibilities I can see. I would love feedback on whether any of these would work, or if there are even better options. 1. start with

How to create a forum topic programmatically?

烈酒焚心 提交于 2020-01-12 10:39:50
问题 I just gone through how to create forums and containers programmatically with the below link http://www.unibia.com/unibianet/drupal/how-create-drupal-forums-and-containers-programmatically But never see any post(google) which create forum topic pro-grammatically, whether i should go with node_save() or any alternative. please help me guys, Thanks, Edvin 回答1: A quick, safe and easy way to create new nodes programmatically is to use node_save(): <?php // Construct the new node object. $node =

How can I upload multiple files with drupal 7?

大兔子大兔子 提交于 2020-01-01 19:18:36
问题 I'm making a drupal 7 module that contains a form and I would like to upload multiple files in a row. Currently I'm using a managed_file type of input field. $form['attachment'] = array( '#title' => t('Attachment'), '#type' => 'managed_file', '#default_value' => variable_get('attachment', ''), '#upload_location' => 'public://perm/', ); This gives me the upload button, but only lets me upload one file. Is there a way I can tell this form to upload a file and still keep the option for a second

Can I make the second or later button in a Drupal form the default button?

人走茶凉 提交于 2019-12-25 03:54:50
问题 I have a form in a custom Drupal 6 module built with the Form API, it has 1 or more image_button elements in a list followed by the Save and Cancel buttons. Everything is working fine when clicking the image and standard buttons, they call the submit functions they should, but if I hit the [ENTER] key within any of the text fields in the form the first button in the form is submitted, which unfortunately in this case is an image_button in the list rather than the Save button. This is a

Drupal form submission

自闭症网瘾萝莉.ら 提交于 2019-12-25 01:55:58
问题 I have created a form in drupal. I don't know how to handle the submission. I want to do some selection from database with the values i get from form. Here is my code to create form function q_search_form() { $form['qsearch']['category'] = array( '#type' => 'select', '#options' => array(0 => 'Any', 1 => 'Automotive', 2 => 'Real Estate'), '#attributes' => array('class' => 'drop-box'), '#prefix' => '<table width="470"><tr><td width="170">Select Category</td><td width="300">', '#suffix' => '</td

how do i make diffrent registration form in drupal?

好久不见. 提交于 2019-12-24 06:57:52
问题 Is there a module that can make different registration forms for different roles during sign up? (ex. each Editor,Main User,Sub User role have different form) 回答1: There is :) http://drupal.org/project/autoassignrole to assign by path you will also need Content Profile: http://drupal.org/project/content_profile check out this tutorial on how to pull it off: http://www.web-a-team.com/blog-post/user-registration-more-one-role 回答2: Here's what you should do start with install profile2-7.x-1.2

Drupal 7 Forms API - AJAX Forms error: An illegal choice has been detected. Please contact the site administrator

旧城冷巷雨未停 提交于 2019-12-24 04:49:05
问题 I have a form set up where a users selects an item from a drop down. Once that item is selected another drop down is populated. Then depending on the value that is selected from the second drop down a fieldset may or may not be shown. If the field set is shown there is a field and a button. By clicking the button you add another copy of the same field. Once there is more than one a remove one button shows up as well. I got the basis for the code from here: http://api.drupal.org/api/examples

Drupal 7 FAPI - ajax image preview

僤鯓⒐⒋嵵緔 提交于 2019-12-21 06:38:56
问题 I am trying to preview the uploaded image using ajax in my D7 module but don't know why it's not working. Here is what I am trying to do:- function create_ad_form($form, &$form_state) { $form['image_file'] = array( '#title' => t('Upload Banner:'), '#type' => 'file', ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', '#submit' => array('create_ad_form_submit'), '#ajax'=> array( 'callback'=>'create_ad_form_submit', 'wrapper'=> 'im-area', 'method'=> 'replace', 'effect'=>

Why should I use Drupal's Form API & Ajax framework for this rather than just implementing my own solution with calling node_save()?

橙三吉。 提交于 2019-12-11 23:07:40
问题 I want users to be able to submit nodes and comments via AJAX. I also want to do some fairly extensive customization of the node and comment forms. I've spent time looking through documentation and code examples for Drupal 7's Form API and Ajax framework, but I find it very complex. Therefore, I simply want to create my own form in HTML and use my own JavaScript code to submit it via Ajax. I'll also set up a specific URL for processing these Ajax requests, which will ultimately call node_save

Two forms on the same page drupal

半城伤御伤魂 提交于 2019-12-11 04:48:52
问题 I have a database of clients. Before entering a new client, I want to make sure that that client is not already in the database. So I want to put a search form at the top of my page to search by client number, and client name. Further down the page, I'll have another form to enter and submit the client's information. Would this be the best way to go about something like this? How would you approach this? i'm using drupal 6. 回答1: It is better that when the user is inserting a new customer name