drupal-fapi

How remove node ID [nid:n] in NodeReference fields

给你一囗甜甜゛ 提交于 2019-12-08 01:56:15
问题 This is the same question of this link: Removing [nid:n] in nodereference autocomplete According with the first answer (Grayside) I've created my own module and activated. Then I create a new content, I look sth up in the nodereference field and finally select it -> it works (Doesn't appear the [nid:n]). But, when I view/preview or save or edit the content, the [nid:n] appears again. Anybody can help me? 回答1: When viewing the node, it is the theming function for the field that determines what

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: adding disclaimer text above the submit button in a webform

为君一笑 提交于 2019-12-06 01:36:50
Is there an easy-ish way to modify the webform-form-tpl.php template to show disclaimer text above the submit button in a Drupal webform? I can add text below the button, but do not know how to split up the button from the other elements to add text between them, ie: [form-elements] [disclaimer text] [submit button] Cheers! The easiest option is probably is insert the text as a markup form item using hook_form_alter on the form. This worked for me : $form['actions']['submit']['#prefix'] = 'Disclaimer...'; This doesn't really belong in the theme layer; it's content. You can add the disclaimer

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: Form API, dynamically hide or show fields based on input

↘锁芯ラ 提交于 2019-12-03 16:46:09
问题 I'm building a form module. One of the early fields is a set of radio buttons. By default the first button is selected. Next I'll have a series of select boxes. One needs to be visible, the others invisible. Then as the user selects a different radio button I want different select boxes to show or hide. How can I hide the field and label by default and show it later dependent upon which radio button (or another select box option for that matter) is chosen? 回答1: You can use the #states

drupal: Form API, dynamically hide or show fields based on input

蹲街弑〆低调 提交于 2019-12-03 06:39:06
I'm building a form module. One of the early fields is a set of radio buttons. By default the first button is selected. Next I'll have a series of select boxes. One needs to be visible, the others invisible. Then as the user selects a different radio button I want different select boxes to show or hide. How can I hide the field and label by default and show it later dependent upon which radio button (or another select box option for that matter) is chosen? You can use the #states property to achieve that. The #states property can be applied to all Form API elements. Here's the documentation

How do I hide a CCK Nodereference input widget in #after_build?

…衆ロ難τιáo~ 提交于 2019-12-02 20:01:09
问题 I like simplifying the node form. One of my tricks in the past has been to conditionally hide CCK elements on new node creation when I want to enforce some kind of default. One of my favorite tricks is to whisk away things put in place by the Prepopulate module. Unfortunately for me, it's recent move to an #after_build -based mechanism seems to be creating all kinds of collisions in how I can manipulate the widget. This is what I used to do in hook_form_alter() : $form['field_my_nodereference

How do I hide a CCK Nodereference input widget in #after_build?

拟墨画扇 提交于 2019-12-02 12:21:10
I like simplifying the node form. One of my tricks in the past has been to conditionally hide CCK elements on new node creation when I want to enforce some kind of default. One of my favorite tricks is to whisk away things put in place by the Prepopulate module. Unfortunately for me, it's recent move to an #after_build -based mechanism seems to be creating all kinds of collisions in how I can manipulate the widget. This is what I used to do in hook_form_alter() : $form['field_my_nodereference_field'][0]['#type'] = 'hidden'; $form['field_my_nodereference_field'][0]['#value'] = $form['field_my

Drupal Studs help me with my form_alter hook ( I am almost there)

放肆的年华 提交于 2019-12-02 12:09:30
问题 So I think I am almost there conceptually but need some missing pointers. Objective is to add a few more fields to the normal user registration form, style it a little, then submit it with storing the extra fields in a table. This is what I have so far. Can someone give me the final nudge and get me going. Please help me. Also how do I apply some minor styling like aligning the new form fields ? Thank you so much !!!!!!!!! function module_menu() { $items = array(); $items['school/registration

Drupal Studs help me with my form_alter hook ( I am almost there)

倖福魔咒の 提交于 2019-12-02 03:46:22
So I think I am almost there conceptually but need some missing pointers. Objective is to add a few more fields to the normal user registration form, style it a little, then submit it with storing the extra fields in a table. This is what I have so far. Can someone give me the final nudge and get me going. Please help me. Also how do I apply some minor styling like aligning the new form fields ? Thank you so much !!!!!!!!! function module_menu() { $items = array(); $items['school/registration'] = array( 'title' => 'Upgraded Registration Form', 'page callback' =>'module_school_register', 'type'