drupal-fapi

How to redirect user to a specific page after they login if they belong to a certain role?

We have certain users in our member list that have a role "vendor" attached to them. All such members are to be redirected to a certain page upon login. How can this be accomplished? ...

What is wrong with my Update Query in Drupal 6.x?

There is mixed documentation that I am seeing and thus am confused. db_query( 'UPDATE {db} SET principlename="%s", schoolname="%s", address1="%s", address2="%s", city="%s", computerserialno="%s", state="%s", zipcode="%s", terminalid="%s", admin_first_name="%s", admin_last_name="%s", admin_email="%s", admin_phone="%s" WHERE userid=...

Why is my form not updating as it should?

The submit handler gets the same form values no matter what I put in the form. Why??????? function edit_schoolinfo_form() { global $user; $result = db_query("SELECT * FROM {db} where userid=%d", $user->uid); $sas_school_info = db_fetch_array($result); $form = array(); $form['school'] = array('#type' => 'fieldset', '#...

Form submit handlers with additional arguments

For some requirement I need to pass additional information to form submit handler. In form api, while defining custom submit handler as $additional_args = array(); $form['#submit'][] = 'my_submit_handler' I expect to submit handler as function my_submit_handler($form, &$form_state, $additional_args){ ...

Is it OK to use regular HTML forms as part of .inc files in a Drupal 6.x custom module ?

I inherited a project that seems to have a ton of custom modules. A lot of the modules have includes folders with include files that have regular HTML forms. I know that Drupal preaches using FAPI. My question is that in your experience are there any pitfalls with this approach or is this acceptable use? Thank you ...

Need to add some custom HTML before a form gets returned..How?

I need to display some custom HTML/Processing code before a Drupal form can be shown. How do I return both the custom HTML and the form? The code I have is: function myfunction() { global $base_path, $base_url; $output = ""; // Clear the variable, just in case include ('includes/SOME_HTML_OUTPUT.inc'); return $output; //...

Showing form data after submit

I have a form with a submit button and a handler that stores data in the database. Problem is when the form is submitted, all data is cleared from the input fields. Is there a way to still show them after submit? What changes do I need to make to my form_submit function? function mymodule_form_submit($form, &$form_state) { //how to ret...

How to uninstall a module that overrides the core user module?

One of my developers wanted to override some functionality of the core user module. He made a copy of the core user module and placed it in the sites/all/modules folder. Something in the functionality screwed up and now I am not sure how to uninstall it. I have tried deleting the module from the sites/all/modules folder and it now crashe...

How to get the names of the terms from the field of taxonomy?

In my module, I am trying to get the all names of terms that comma-separated in the field of taxonomy ( for create/edit node ). For example: a,b,c,d : <?php function mymodule_form_alter(&$form, $form_state, $form_id) { if($form_id == 'story_node_form') { $form['#submit'][] = 'mymodule_form_mysubmit'; } } function mymodule...

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

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

Using reCaptcha, Lightbox, and Drupal's Form API together

I've been wading through the issues of putting a Drupal form in a Lightbox2 lightbox. Perhaps wrongly, I've resorted to doing all the validation in javascript before submitting the form (I couldn't make the normal validation return the form within the lightbox). Anyway, i'm using: $form['#attributes']['onsubmit'] = 'return Drupal.m...

Does variable_get in Drupal have major issues with memcache?

On a few modules there is a variable_get that is pulling either the correct setting (toboggan/denied) or (node/200) even though the {variable} table is set to toboggan/denied? where is the node/200 coming from and why the randomness in values? Is this a caching issue? This problem is causing us to not be able to set admin settings on mod...

Drupal jquery submit form without submit button

Hi, I have a drupal form which i post using jquery when you select an option from a selectlist (a sort of quicksearch selectlist). The porblem is that when i submit by clicking the button, it works. When I use jquery, and the button is in the form (hidden or not), it works. When I use jquery and I rmove the button, the post is done, bu...

Drupal cck checkbox with global setting

Hi, I am creating a "sticky" checkbox for my content type "news". this means that one news node is sticky, and is used in a banner like box. This is marked by a checkbox int the cck create content form. The checkbox is handled by the node_api, so I check: if $op = 'update' and $node->type = 'news' then ... logic. I don't know why bu...

Drupal 6 Form Api adding an item to an existing form.

Please delete duplicate question ...

Drupal 6 Form Api adding an item to an existing form.

I want to add a new item into an existing form. I have the ID of the form and I know I need to use hook form_alter but not sure how to add it. function modulename_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { case 'form id goes here': // Need to do something here.... break; ...

Drupal 6 editing the submit function on a content type

I have a content type and I wish to edit the submit function. I thought the way you would do this would be as follows: function moduleName_contentType_node_form_submit($form, &$form_state){ drupal_set_message(t('Test')); } I cleared the cached but the message is not being displayed on the screen. Am I doing this correctly or do I ...

Drupal 6 getting the node title from a submitted form

I am using form_alter to edit the submit function when editing content. In my custom function I wish to edit a custom message to the screen with the title name. I thought a way I could do this is something as follows function mymodule_myfunction(&$form) { drupal_set_message(t('Some text ' . $form['#node']->title)); } The title is ...

Drupal hook fired after node created

When I create a node I want it to programmatically create some nodes that reference the node just created. I though I would just need to change form_alter submit function for my form to call a custom function to create the nodes. Examining the output $form_state I can see that the NID is Null. This would mean to me that my node is crea...

how can one override default registration email in a hook form alter registration?

The main site sends a registration email and I do not want that email to be sent to this new registration as it should have its own custom email. I am having a hard time with this because every time a user registers either on main registration or this custom registration, they get the same mail. How can i keep my custom registration mail...