Hi all,

Hoping you can give me some guidence. I have a site that I am porting from an existing site I manually coded to a module in drupal. I am having trouble finding out how I am going to get this right.

I am wanting to reformat the form so that it looks like the image below. If I use checkboxes they all sit below each other. I need for these to sit next to each other. I have looked at theming and at the forms API and can't see anything that allows me to do this. Is there any way of doing something as part of the FORMS API?

Image of layout

Any assistance would be greatly appreciated.

Kind Regards,
Davin

Comments

carnevaledesign’s picture

Try this link: http://api.drupal.org/api/file/developer/topics/forms_api.html/6. If you are using 5.x, go here: http://api.drupal.org/api/file/developer/topics/forms_api.html/5. Scroll down to the "Theming Forms" section.

WorldFallz’s picture

AFAIK, you'll have to do this with theming. Setup the cck form with all the groups and check boxes you need. Then theme the presentation of the form to get the appearance the way you want-- i would probably just do it the easy way with a table though it could probably be done with divs.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz

Trappies’s picture

Ah,

Thanks for the quick responses. I have had a look at the form theming and that doesn't seem to have any effect.

I did as follows :


function theme_aonline_estab_add_form($form) {
  $output = '';
  $output .= drupal_render($form['e_details']['e_name']);
  $output .= '<div class="foo">';
  $output .= drupal_render($form['e_details']['l_postal_1']);
  $output .= '<div class="bar">';
  $output .= drupal_render($form['e_details']['l_postal_2']);
  $output .= '</div></div>';
  $output .= drupal_render($form);
  return $output;
}

function aonline_estab_add_form() {

$form['e_details'] = array(
		'#type' => 'fieldset',
		'#title' => t('Establishment Details'),
		'#collapsible' => TRUE,
		'#collapsed' => FALSE,
		'#tree' => TRUE,
	);
	
	$form['e_details']['e_name'] = array(
		'#type' => 'textfield',
		'#title' => t('Establishment Name'),
		'#size' => 30,
		'#maxlength' => 64,
		'#description' => t('Enter the name for this group of settings'),
	);

// whole lot more...

return $forum;
}

This has absolutely no effect. :\

Also, I would like to minimize the use of external packages like CCK. I used tables before and that would be great to use again. Can I use tables or divs with the FORM API? Or is there another way of doing it?

Regards,
Davin

WorldFallz’s picture

I can definitely understand minimizing module mania, but i can't imagine there are many sites that don't at minimum install cck (along with one or more field type modules) and views (and probably nodequeue).

I do all my forms with either cck or webform, hopefully someone who knows more about the fapi will reply.

===
"Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime."
-- Lao Tzu
"God helps those who help themselves." -- Benjamin Franklin
"Search is your best friend." -- Worldfallz