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

form api: return $form vs. $output

Hi!

I already read the handbook pages about 4.7's new form api, but I still dont understand how to use it
correctly. I wrote a simple test module to play with the api:

function formtest_settings() {

  $form['global'] = array(
    '#type' => 'fieldset',
    '#title' => t('form_group'),
  );

  $form['global']['formtest_enable'] = array(
    '#type' => 'radios',
    '#title' => t('Test Radios'),
    '#default_value' => variable_get('formtest_enable', 0),
    '#options' => array(t('Off'), t('On')),
  );  
  
  $options = array();
  $options[0] = "Choose Option";
  $options[1] = "Option A";
  $options[2] = "Option B";
  
  $form['global']['formtest_method'] = array(
    '#type' => 'select',
    '#title' => t('Test Select'),
    '#default_value' => 1,
    '#options' => $options,
    '#description' => t('Sample Desciption'),
  );
  
  //$output = form_render($form);
  //$output = drupal_get_form('testform', $form);
  //return $output;
  return $form;
  
}

The code works nicely with return $form, but when I try one of the other lines and return $output
I receive "Fatal error: Cannot use string offset as an array in ...\system.module on line 728"
Whats wrong with my code? What function should I use form_render or drupal_get_form?

As long I must use return $form, I'm unable to apply special format to my output,
e.g. $output = theme('table', $header, $rows) is not possible then.

Hoping for help, Thilo

My implementation of inline forms for Drupal 4.7

Hello everybody =)

I'm developing an ajax widget that runs on Drupal 4.7 to easily implement inline forms (note: this is different from autocomplete. A good inline form example is http://www.baekdal.com/x/xmlhttprequest/). It is already basically running, but using xajax as library (along with the xajax module from CVS). I don't have the primary intention to be merged to the core (and that's why I'm using xajax -- and we know that 3rd party libraries don't get merged into the core). I would like to know if 1) is this something that interests everybody and deserves to be developed using the core stuff for ajax instead of xajax and 2) is there anobody here already working with inline forms. If somebody thinks that this will be useful to be published, let me know =)

Currently, to make your form "inline", you need to setup a 3rd callback called _inline, that will handle the field changes. So, let's suppose that you have a simple form with : "Name", "E-mail", "Login" and "Password" and you want to let the user know if the login is already taken in real time (as in gmail and others), and your form is called "user_register".

drupal_get_form('user_register', $formfields);

and you have the default callbacks (_submit and _validate)

function user_register_submit($form_id, $values) { }
function user_register_validate($form_id, $values) { }

and on my model, you create a 3rd one

Accessing $node fields from a block

Hi everybody..

is there a smarter way to access $node fields from a block
than this?

if(arg(0)=='node' && is_numeric(arg(1))) {
    if($node = node_load(arg(1))) {
....
  }
}

The problem is that using this while browsing a node page
will duplicate each query which load the node fields.
This is not needed becouse them are already been loaded once.

Does someone has ideas?

Thanks

Fabio

Map APIs: Google vs. Yahoo vs. ?

I'm trying to decide which route to go for a website that needs to identify and display areas on a map in which given coordinates are located. The coordinates correspond to a location (street address). The areas are custom boundaries. So, the location would be displayed and then the boundaries of the area would be displayed with a location to get more information on the area that contains the location.

What have been people's experiences with Google, Yahoo, and other mapping systems and Drupal modules? What do you think might fit this project best?

Thanks.

Problem with feed RSS (aggregator2 module)

The standart RSS module works fine, but aggregator2 with the same link get error:

Failed to parse RSS feed ...

Can you give me some hints?

Sorry for poor English :)

MIME type warning

what do this warning means?

For /tmp/phpqpzpOP the system thinks its MIME type is application/x-zip while the user has given application/x-zip-compressed for MIME type

Pages

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