Hello, This is working very well:
$form['details'] = array(
'#type' => 'fieldset',
'#title' => t('Common Information'),
'#tree' => TRUE,
'#attributes' => array('class' => 'fieldset-details'),
);
I can thee the fieldset-details class in the source code. But this doesn't work:
$form['order-left'] = array(
'#type' => 'item',
'#prefix' => '<div class="global-order"><div class="order-left">',
'#attributes' => array('class' => 'hide-item'),
);
I cannot see the class in the source code.
It's the same with this:
$form['results'] = array(
'#attributes' => array('class' => 'buisness'),
'#type' => 'item',
'#title' => t('Price'),
'#value' => _order_price_format_values(array('0' => '0 €')),
);
I got the theming table and the title but the class doesn't appear. What's the problem ?
Thank you !
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | forms_api_reference.html_.patch | 2.25 KB | steven jones |
Comments
Comment #1
damien tournoud commentedComment #2
ainigma32 commentedAFAICS this behavior is by design so the bug is in the API documentation for D6: http://api.drupal.org/api/file/developer/topics/forms_api_reference.html... shows that you can use the
#attributesproperty for an#itemwhile http://api.drupal.org/api/file/developer/topics/forms_api_reference.html... does not have#itemin the Used by: section. AFAICS the latter is correct.From form.inc line 1843 and further:
The code goes right to
theme('form_element',...and does not process the #attributes property (as it says in the comments).I'm marking this as a bug for documentation. If you want to use the #attributes property you should create a separate issue and mark it as a feature request for D7.x
- Arie
Comment #3
YoyoS commentedThx for your answer. It's ok for me, i did it in another way. I used the suffix and prefix value to manage the item. I don't know if there is a better way. I'm a very beginner with drupal and about theming, I just know how to create a table :D
My little hack:
If I understand you, I could do the same with your function
If you could explain a little please :)
Thx you !
Comment #4
ainigma32 commentedI just referred to the code in form.inc so you could see that the #attributes value isn't used for #item
I think your workaround looks just fine and you know what they say: if it ain't broken, don't fix it :-)
- Arie
Comment #5
add1sun commentedCore and API docs go in the Drupal project queue.
Comment #6
steven jones commentedWorking on this...
Comment #7
steven jones commentedHere's a lovely little patch for the form API reference bit, because I seem to have lost commit access for the file. Patches will be needed for 6,5,4.7 etc.
Comment #8
steven jones commentedFixed in D7 and D6 versions.
Comment #9
steven jones commentedFive needs work too!
Comment #10
steven jones commentedShould now noe be fixed in all versions, please wait for a.d.o to refresh the content!