hook-form-alter

drupal alter node edit form

可紊 提交于 2019-12-20 10:27:13
问题 How can I add a custom configuration area to a node edit form just beneath the Authoring Information & Publishing Options section? 回答1: You can use hook_form_FORM_ID_alter(). Example below: function my_module_form_node_form_alter(&$form, $form_state) { // if you are targeting a specific content type then // you can access the type: $type = $form['#node']->type; // Then if ($type == 'my_content_type') { // use a contact settings for the sake of this example $form['contact'] = array( '#type' =>

Using Hook_form_alter on webform submitted values

泪湿孤枕 提交于 2019-12-13 03:56:52
问题 Drupal 7. Webforms 3.x. I am trying to modify a webform component value on submit. I made a custom module called 'mos' and added this code to it. function mos_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'webform_client_form_43') { dsm($form['#node']->{'webform'}['components']['1']); $form['#submit'][] = 'mos_contact_us_submit'; } } function mos_contact_us_submit($form, &$form_state) { $form['#node']->{'webform'}['components']['1'] = 'working@mos.com'; } However when I look at

Drupal 7: How to alter image field widget “alt” or title" label

烈酒焚心 提交于 2019-12-09 18:47:46
问题 I am trying to change the "alt" and title" labels in the Image Widget on the node add form. I have tried both of these hooks: hook_field_widget_form_alter hook_form_alter I was unable to find where I needed to go to successfully alter the label. Could some one please direct me to the appropriate way to hook into this and alter them? I'm hitting these from a custom module if it makes a difference. Hitting them via the theme would be fine for me as well. Any ideas anyone? 回答1: You have to add

set webform component value using hook_form_alter in drupal [closed]

拜拜、爱过 提交于 2019-12-07 09:25:01
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have used form_alter function to change the value of a component but it does not change and default values is stored in the db. when i print the $form the updated values is displaying but not saved in db. <?php

Drupal 7: How to alter image field widget “alt” or title\" label

孤街浪徒 提交于 2019-12-04 14:36:23
I am trying to change the "alt" and title" labels in the Image Widget on the node add form. I have tried both of these hooks: hook_field_widget_form_alter hook_form_alter I was unable to find where I needed to go to successfully alter the label. Could some one please direct me to the appropriate way to hook into this and alter them? I'm hitting these from a custom module if it makes a difference. Hitting them via the theme would be fine for me as well. Any ideas anyone? TheodorosPloumis You have to add an extra Proccess function for the widget form. You can also use dpm($element) with Devel