drupal-forms

Drupal 7 FAPI- Adding form elements in validate or submit handlers

懵懂的女人 提交于 2019-12-07 17:33:35
问题 Is it possible to add additional form elements in the validate or submit functions in drupal 7 module? The following code works and image is displayed on the form: function test1_form($form, &$form_state) { $form['image']=array( '#markup'=>'<img src="sites/all/modules/create_ad/th.jpeg"><br/>', //replace with your own image path ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', ); } but when I try to display image after submission in submit function like following, it

Drupal 7 - add HTML inside #link form type entry?

笑着哭i 提交于 2019-12-07 11:49:34
问题 I need to add HTML markup to the #title field of a Drupal 7 #type link form element. The output should look roughly like this: <a href="/saveprogress/nojs/123" id="saveprogress-link" class="ajax-processed"> <span data-icon="" aria-hidden="true" class="mymodule_symbol"></span> Save Progress </a> Since I'm doing some ajax forms, I can't just use #markup and l() function. Here's an example without the span: function mymodule_save_progress_link($nid) { return array( '#type' => 'link', '#title' =

Remove class=“form-item” from Drupal forms

微笑、不失礼 提交于 2019-12-07 11:08:51
问题 Drupal automatically adds <div>'s and classes around form items. All form elements will have the attribute class = "form-item" . How do I override this default behavior? 回答1: If you insist on changing it, it's added in the theme_form_element function. You can override it by copying that function to your theme's template.php file and renaming it THEMENAME_form_element (substituting the name of your theme in place of "THEMENAME") or phptemplate_form_element and removing the part that adds the

Drupal login form customize

你说的曾经没有我的故事 提交于 2019-12-06 12:19:04
问题 Hi i have used this code <?php $elements = drupal_get_form("user_login"); $form = drupal_render($elements); echo $form; ?> to get the default Drupal login form for my site but I need to customize the HTML, I have found some pages in module/users but did not understand how to customize the structure. 回答1: use this in template.php function themename_theme() { $items = array(); $items['user_login'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'corporateclean') . '

Create multiple CCK nodes with single custom form in Drupal

元气小坏坏 提交于 2019-12-05 21:39:02
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 the standard node creation form for content type foo. modify the form by adding fields for content type

Drupal 7 - add HTML inside #link form type entry?

我是研究僧i 提交于 2019-12-05 21:28:31
I need to add HTML markup to the #title field of a Drupal 7 #type link form element. The output should look roughly like this: <a href="/saveprogress/nojs/123" id="saveprogress-link" class="ajax-processed"> <span data-icon="" aria-hidden="true" class="mymodule_symbol"></span> Save Progress </a> Since I'm doing some ajax forms, I can't just use #markup and l() function. Here's an example without the span: function mymodule_save_progress_link($nid) { return array( '#type' => 'link', '#title' => t('Save Progress'), '#href' => 'saveprogress/nojs/' . $nid, '#id' => 'saveprogress-link', '#ajax' =>

Remove class=“form-item” from Drupal forms

余生长醉 提交于 2019-12-05 11:46:54
Drupal automatically adds <div>'s and classes around form items. All form elements will have the attribute class = "form-item" . How do I override this default behavior? If you insist on changing it, it's added in the theme_form_element function. You can override it by copying that function to your theme's template.php file and renaming it THEMENAME_form_element (substituting the name of your theme in place of "THEMENAME") or phptemplate_form_element and removing the part that adds the class. In real experience these are useful classes, but if you want to extremely clear form you can theme

How can I upload multiple files with drupal 7?

微笑、不失礼 提交于 2019-12-04 19:36:18
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 upload open? check out the new ajax system, it's pretty easy to implement, it should allow you to

Drupal login form customize

好久不见. 提交于 2019-12-04 19:35:35
Hi i have used this code <?php $elements = drupal_get_form("user_login"); $form = drupal_render($elements); echo $form; ?> to get the default Drupal login form for my site but I need to customize the HTML, I have found some pages in module/users but did not understand how to customize the structure. use this in template.php function themename_theme() { $items = array(); $items['user_login'] = array( 'render element' => 'form', 'path' => drupal_get_path('theme', 'corporateclean') . '/templates', 'template' => 'user-login', ); and create a template folder and within that create a file user-login

How to create a forum topic programmatically?

三世轮回 提交于 2019-12-03 21:37:02
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 A quick, safe and easy way to create new nodes programmatically is to use node_save() : <?php // Construct the new node object. $node = new stdClass(); // Set the values for the node $node->title = "My new forum topic"; $node->body = "The body