drupal-fapi

Drupal 6 Validation for Form Callback Function

岁酱吖の 提交于 2020-01-17 03:27:12
问题 I have a simple form with a select menu on the node display page. Is there an easy way to validate the form in my callback function? By validation I don't mean anything advanced, just to check that the values actually existed in the form array. For example, without ajax, if my select menu has 3 items and I add a 4th item and try to submit the form, drupal will give an error saying something similar to "an illegal choice was made, please contact the admin." With ajax this 4th item you created

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 use hook alter form in module to register a user and also save some data in another table?

烈酒焚心 提交于 2020-01-06 01:57:07
问题 have a general idea on how to use hook alter to modify the feel of the registration form . However the challenge I have is to not only have the user register, but to save some extra data into another table and then redirect user to a new page. How would I get about doing that? Please help 回答1: Again, it'd be easier to plan what you're trying to do and take advantage of common solutions. I suspect what you're after is the Content Profile module. 回答2: add a custom function to your form,

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'=>

Validation on user registration form?

耗尽温柔 提交于 2019-12-14 03:19:08
问题 i have made module in which i am trying to add validation like if the user had entered the characters in "Phone No" text filed and same on "Mobile No". This will run when user had open the user registration form. I have made this.... <?php function form_intro_form_alter($form_id,&$form){ if($form_id == 'user_register' || $form_id == 'user_edit'){ $form['Personal Information']['profile_pno']['#validate'] = array('form_intro_pno_validate' => array()); //profile_pno is for Phone No. $form[

What is the opposite of Access Callback user_is_anonymous?

给你一囗甜甜゛ 提交于 2019-12-13 14:40:49
问题 I know that is used in a drupal module to specify that only anonymous users can see that module. What would be the callback that specifies only logged in users ? I have a page that I only want accessible to logged in users. Thank You 回答1: It is the user_is_logged_in() function, which basically checks that the user's ID ($GLOBALS['user']->uid) is greater than zero. The function converts the uid into a Boolean type and returns TRUE for any user that is logged in, because they would have a uid

Including results along with a form on the same page and theming the results using drupal

半世苍凉 提交于 2019-12-12 10:23:15
问题 I have successfully created a page in drupal that displays a form and results on the same page. The form acts like a filter of the results. The results include a bunch of html that includes google charts via the Chart API module (http://drupal.org/project/chart). The results are included in the form via a markup form element (Got that from eaton's comments here: Drupal: How to Render Results of Form on Same Page as Form). Since I can't access the form results outside of the scope of the form

need some tips on Drupal $form value

為{幸葍}努か 提交于 2019-12-12 01:32:23
问题 I got dpm($form) working. Nice! This is much better way to view data. I am still trying to figure out where stuff is coming from eg: location longitude & latitude. The word 'longitude' is referenced in 20 different places. I thought this was a likely place to isolate text box for this input field. dpm($form['#field_info']['field_store_latitude']['location_settings']['form']['fields']); Any tips on how to track down individual input elements? ** this is not an answer, but a supplement to my

Drupal form submission to a 3rd party website

你。 提交于 2019-12-11 11:47:20
问题 I'm building a form in Drupal that needs to submit to a 3rd party website. Within the form API it seems like this is not really possible as you register form submission handlers to do all of the processing. I need to have the form method to to POST and it needs to be submitted to this website as it is a 3rd party hosted ordering system. Has anyone run into a similar situation? Any suggestions? 回答1: Use the #action attribute on the form array: $form['#action'] = 'http://example.com'; 来源: https

Drupal: adding disclaimer text above the submit button in a webform

孤街浪徒 提交于 2019-12-10 09:52:17
问题 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! 回答1: The easiest option is probably is insert the text as a markup form item using hook_form_alter on the form. 回答2: This worked for me : $form['actions']['submit']['