I just want to create a form with two fields one besides the other <textfield>.<select> - wanting the user to be able to write his own subdomain, and select the main domain from a list (as seen in dyndns.com, for example, when selecting a host name...).

I want to stick to the Forms API...
Any idea ?

Comments

profix898’s picture

You only need to write a simple theme_() function to wrap your FAPI fields into table cells.

The FAPI part ...

$form['test'] = array('#theme' => 'mytest');
$form['test']['fieldA'] = array(
  '#type' => 'textfield',
      '#title' => '',
      '#default_value' => '...',
      '#size' => 50
);
$form['test']['fieldB'] = array(
  '#type' => 'select',
  '#title' => '',
  '#default_value' => '',
  '#options' => array(
    'abc' => 'abc'
  )
);

The theme_() function ...

function theme_mytest($form) {
  $rows = array(
    array(
      drupal_render($form['fieldA']),
      drupal_render($form['fieldB'])
    )
  );
  
  $header = array('', '');
  return theme('table', $header, $rows);
}

The code is untested. It might need some more formatting to create the output you expect, but it should work basically.