drupal-fapi

How does drupal choose which function to process a form submit?

I'm really confused,can someone clarify this? ...

Pass form data from block to a page view in Drupal

I am using the location module and views module for a postcode search, which works fine in a page display using views. However I want the user to be able to enter their postcode into a block on the homepage and clicking submit my module sends them to the page created in views and the postcode is set as a session S_SESSION['postcode'] b...

Drupal FAPI: Add form elements on nodeform after validation

Hi, I use Drupal 6.x. In my own module I alter each node form an add my own validation handler to it using $form['#validate'][] = 'my_own_validation_function'; Then I have the function function my_own_validation_function($form, &$form_state) { //if validation fails, i would like to rebuild the form to add additional form elements i...

Why would a Drupal form not be cached in cache_form?

My form, lets call it organize_issue, is a form in a custom module being called from the menu using the page callback drupal_get_form function. The form works perfectly well. I'm trying to implement some AHAH type functionality now, and need to get the page from cache using form_get_cache($form_build_id, $form_state) but, oddly enough, ...

Registration during content creation in Drupal?

Is there an easy way to allow a user to register as he creates content type. E.g. Let's say there is a content type called "listing". When the user clicks to on a link to create it, and he's not logged in, I want a "register" box to appear ABOVE THE CONTENT CREATION area, where the user can enter his normal registration details. Is this ...

[Drupal Forms API] form_set_error on taxonomy fields?

Hi everyone, While form_set_error('field_firstname', t('message')); works fine, how can I do the same for one of several taxonomy fields? e.g. form_set_error('taxonomy[5]', t('message')); (which doesn't work). Can anyone help? ...

How to use hook alter form in module to register a user and also save some data in another table?

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 ...

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

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...

How to override form just on one page?

OK so this is my hook form alter function.It is causing all the registration forms on site to be over written which I do not want as I just want it on this page. function special_registration_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'user_register') { drupal_set_title(t('Custom registration')); $form['fir...

Most efficient way to have a 50 state drop down box in Drupal Forms

I know that one way is to have a table in database with all the states and then you would read it in your form. Is there any easier way in your opinion guys ? I feel bad asking for something like this since it is so elementary however I would suppose something as simple like this would already be implemented in Drupal. ...

What is the opposite of Access Callback user_is_anonymous?

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 ...

Drupal SQL injection attacks prevention and apostrophe handling in Forms

in typical PHP applications I used to use mysql_real_escape_string before I did SQL inserts. However I am unable to do that in Drupal so would need some assistance. And without any sort of function like that, user input with apostrophes is breaking my code. Please suggest. Thank You My SQL is as follows: $sql = "INSERT INTO some_tabl...

Redirect form in validation fail

I have a situation that if my form doesn't validate I need it to remove all but the first argument from the url. The reason for this is because the results of my form are displayed below the form in the content area. If the form doesn't validate I need to remove any previous results. I am have tried the following in my form_validate fun...

Drupal drupal_get_form

I trying to get the twitter_admin_form and twitter_user_settings form in a div. /** * Get twitter form for user * @param $account * @type user object */ function getTwitterForm($account){ //module_load_include('inc', 'twitter'); module_load_all(); $twitter_form = drupal_get_form('twitter_admin_form');...

How to reset radio buttons selections on postback?

This is a Drupal Forms question. I am working on a UI that dynamically creates rows of 3 radio buttons based on a selected date. The problem I am having is that if I make some selections of the radio buttons and choose another date to get another set of radio buttons, the radios that were in the first list maintain their selected status...

hook_form_submit not being called

I'm trying to submit a form and use hook_form_submit. The problem is the form is displayed via ajax and this results in hook_form_submit not being called. $items['ajaxgetform/%'] = array( 'page callback' => 'ajaxgetform', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK ); function ajaxgetform($f...

How to hide Date of birth field in overriden form?

In my hook form alter, this is the date of birth array: [Birthdate] => Array( [#type] => fieldset [#title] => Birthdate [#weight] => 1 [profile_birthdate] => Array( [#type] => date [#title] => Birthdate [#default_value] => [#description] => The content of this field is kept private and will not be shown publicly....

In Drupal 7, how do I show a new form that can edit data selected from a different form?

I have a tableselect form that lists several items. When a user selects one or more items, and clicks the edit button, I want a new form to show up that lets them edit the items. I have the new form structure being generated, but I can't get it to show up after the edit button is clicked. Currently, nothing seems to happen. I know that...

Drupal (FAPI) Creating a CRUD html table

Heya, I am creating a module, and am creating a function that creates a html table from one of my tables in the datasbase. function _createtable($tablename, $return = array()){ $html_table = ""; $query = 'SELECT * FROM {'.$tablename.'}'; $count = 10; $pager = pager_query($query, $count); $results = db_query($query); if (db_affect...

How does the Drupal 6 Batch API work?

I've been using the Batch API successfully to do processing that would normally lead to PHP timeouts or out of memory errors, and it's been working nicely. I've looked through the code a little, but I'm still unclear about what's happening behind the scenes. Could someone familiar with the process describe how it works? ...