There is no mention of the 'item' type in the forms api documentation:
http://api.drupal.org/api/4.7/file/developer/topics/forms_api_reference....

It's missing from the HEAD docs too.

CommentFileSizeAuthor
#7 item.patch8.88 KBRobRoy

Comments

RobRoy’s picture

Status: Active » Fixed

I just noticed '#type' => 'item' is used in the forward.module. AFAIK there is no 'item' FAPI type. Since it doesn't exist, the default type 'markup' is used.

jax’s picture

It's also used in the image_attach module and a lot of core modules:

$ grep "type' => 'item'" *.module
comment.module:      $form['_author'] = array('#type' => 'item', '#title' => t('Your name'), '#value' => theme('username', $user)
contact.module:      $form['from'] = array('#type' => 'item',
contact.module:      $form['to'] = array('#type' => 'item',
menu.module:      $form['menu']['advanced'] = array('#type' => 'item',
menu.module:  $form['settings_links']['intro'] = array('#type' => 'item',
menu.module:  $form['settings_authoring']['intro'] = array('#type' => 'item',
menu.module:    $form['_path'] = array('#type' => 'item',
search.module:  $form['basic'] = array('#type' => 'item', '#title' => $prompt);
system.module:        $form['themes'][$info->key]['description'] = array('#type' => 'item', '#title' => $info->name,  '#value' => dirname($info->filename) . ($info->name == variable_get('theme_default', 'bluemarine') ? t('<br /> <em>(site default theme)</em>') : ''));
system.module:  $form['settings'] = array('#type' => 'item', '#value' => $status);
system.module:    $form[$info->name]['description'] = array('#type' => 'item', '#title' => $info->name,  '#value' => dirname($info->filename));

Since it is used in so many places I think the docs should at least mention something about it...

jax’s picture

Status: Fixed » Active

Even if it's just something like: "Since it doesn't exist, the default type 'markup' is used."
I saw it in the code, wanted to know what it does, checked the docs, found nothing. So just the sentence above would already be helpful.

And I would like to know which attributes it supports, because I'm under the impression that it doesn't take #attributes.

RobRoy’s picture

I think one of the higher ups should comment here. We should either document it like Jax is saying OR submit patches to change those '#type' => 'item's to markups (we could remove the lines altogether but I think it is better to be explicit for learning's sake). I'd prefer the latter since it would avoid confusion in the future and there's no need to lead people to believe that we have duplicate types.

chx’s picture

function theme_item($element) {
  return theme('form_element', $element, $element['#value'] . $element['#children']);
}
function theme_markup($element) {
  return $element['#value'] . $element['#children'];
}

Item is a form element and rendered as many other form elements, with an enclosing div, a possible title (w/ label) and possible description. All these are missing from markup.

RobRoy’s picture

I stand corrected...and lazy since with a bit of looking I could have actually researched that. My bad. Good call Jax and chx. :P

RobRoy’s picture

Status: Active » Needs review
StatusFileSize
new8.88 KB

I thought I had write access to DOCs repo. Can someone grant me those? Here's the patch I was going to commit to DRUPAL-4-7.

RobRoy’s picture

Status: Needs review » Fixed

NM, I was logged in as anonymous. Fixed in DRUPAL-4-7.

jax’s picture

I don't want to be a pain, but please don't forget HEAD. Else I'll run into the same problem in a couple of months...

RobRoy’s picture

Fixed in HEAD. Someone should take a look and see if anything needs changing but at least the info is there now. Thanks Jax!

Anonymous’s picture

Status: Fixed » Closed (fixed)