I try to use 'item' type, as the last code example show in this section:
http://drupal.org/node/224333#markup
But Drupal doesn't render any html output.
For example:
<?php
$form['something'] = array(
'#type' => 'item',
'#title' => 'Title',
'#markup' => 'value',
);
?>
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Screenshot-2.png | 3.95 KB | rfay |
Comments
Comment #1
naraku commentedThe problem is the default value of #title_display.
if #title_display is unavailable, then item won't be displayed.
Notice: Undefined index: #title_display in theme_form_element() (line 3373 of /var/www/drupal7/includes/form.inc).
This information about #title_display trick is not in documentation. Is it a bug?
I think, If #title_display doesn't set by user (!isset($element['#title_display'])), then should have a default value, for example 'before'.
Following code works:
Comment #2
tstoecklerI'm pretty sure this isn't critical.
Comment #3
rfayI can't duplicate this. Just tried this:
It worked perfectly, as I expected. I've used it in other code as well.
Comment #4
naraku commentedI want to show a title and a value in one element, as I read in the documentation.
Here is the documentation about it:
http://drupal.org/node/224333#markup
This code is work:
<?
$form['something'] = array(
'#type' => 'item',
'#title' => 'Title',
'#title_display' => 'before',
'#markup' => 'value',
);
?>
This displays similar this:
Title:
value
You've made this with two element. But it should work in one item element, without #title_display. See: http://drupal.org/node/224333#markup
But it doesn't work without #title_display.
There is a bug in parser code or in documentation.
Comment #5
rfayI apologize - I didn't really write what I meant. This code works perfectly for me.
This is the result:

Comment #6
naraku commentedI didn't write about the context. Sorry.
It works perfectly for me too In form context as you try it.
The my context is the hook_view() function. I defined a custom node, and I try to define a custom node view:
I also defined the other node functions. I've created a new node, and a I've viewed it.
But drupal didn't show my_item.
But I've got a PHP notice:
Notice: Undefined index: #title_display in theme_form_element() (line 3373 of /var/www/drupal7/includes/form.inc).
I see the following in the HTML source:
It works with #title_display => 'before' option.
Comment #7
rfayYou're trying to use a form element as if it were a render element. You even used the Form API document as your source for the information. But render types are a small subset of form types, and 'item' is a form type, unless I'm mistaken.