This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Form Cancel Button w/ Required Elements

I'm looking for ideas here...

I'm revisiting the code to the Ubercart checkout form which you can get to through the "work-in-progress" site at http://livetest.ubercart.org. On the checkout page is a Cancel button that takes the user back to the cart view page. The checkout screen naturally has some required fields to collect customer information.

Now, with a Cancel button, you obviously don't care if the customer has filled out all the required fields. I could just do a switch on $form_values['op'] and if I see t('Cancel') then I send them back to the cart screen. However, it has to go through validation before it ever gets to the submit function, so in validation it's throwing up a bunch of errors for those incomplete fields. This just won't do...

So, I used simple Javascript in that form to put ('onclick' => 'window.location = '. base_path() .'"cart"; return false;') in the attributes. That'll kick us out to where we want to go, and in other places also I've used return false; to keep a form from submitting. The question I have is... what in the world can I do for users who aren't using Javascript? (In this situation and others.)

Is there a way to keep the FAPI from trying to validate these required fields? Right now the button type is useless in FAPI, and I'm not sure that '#submit' => FALSE does anything either.

Up for suggestions or questions if I

limiting nested Forum

I love the possibility for Threaded listing for the comments, but it fucks up your layout, so I would like to limit the number of replies on a comment, is this possible?

Redirecting a user to another node after submitting an html form...

Hello everyone:

I currently control view of menh blocks based on user roles, and have a page where users can change their role, however after posting the change to the database, the web page isn't reloaded and the blocks remain visible, making the whole process a bit messy.

How can I redirect a user to another node/reload the page when they click the form submit button?

The form submit button should act as a link...

Thanks!
Adam

Conditional Statement based on 2 values in the database

Hello everyone:

I have logintoboggan running and the redirects page to take users to the following page after login to choose their roles. At the moment it is a system of checks to either add or remove a certain role, but I'd like to make it so they only show up to add a role if they arent that role and only display to remove it if they aren't. Basically, I want a conditionals statement to display the form elements only if the users id and role id match that.

Here is the working model without conditionals, it just looks terrible if someone tries to add a role as a fan by accident if they are one and they get a database duplicate error, I want it to only show relevant choices... I got the idea from here: http://drupal.org/node/28379#comment-128757


<?php

global $user;

if ($_POST["AddFan"] == "Upgrade")
{
$userid = $user->uid;
db_query("INSERT INTO {users_roles} (rid, uid) VALUES ('%d','%d')", 4, $userid);
}

if ($_POST["AddBand"] == "Upgrade")
{
$userid = $user->uid;
db_query("INSERT INTO {users_roles} (rid, uid) VALUES ('%d','%d')", 5, $userid);
}

if ($_POST["AddBiz"] == "Upgrade")
{
$userid = $user->uid;
db_query("INSERT INTO {users_roles} (rid, uid) VALUES ('%d','%d')", 6, $userid);
}

if ($_POST["RemoveFan"] == "Downgrade")
{
$userid = $user->uid;

Unable to translate contrib modul

I have just made a Norwegian translation of the Weather module http://drupal.org/project/weather, but the weather module just don`t want to get translated. What I`m doing wrong here?

Altering an already altered form - changing taxonomy select boxes

The form API proposes a way to alter forms, but as far as I understand, one cannot alter the already altered parts of the form.
An example would illustrate the problem:
The taxonomy select boxes are generated through the taxonomy_form_alter function. Let's say I want to change all the select menus of the taxonomy terms, into checkboxes. The most intuitive way of doing so, is using form_alter:

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions