I have a requirement to add a class to ul li on the user_profile_form edit page on admin side. Using Hierarchical Select Taxonomy module regions are listed on this form.The purpose is to modify the listing of the regions by adding different classes for the regions based on the taxonamy id.
1 Answer
You can do it 2 ways. One is to modify the element attributes, like this:
$form['textfield'] = [
'#type' => 'textfield',
'#attributes' => [
'class' => [
'ul',
]
],
];
Or, another way, wrap the elements with '#prefix' and '#suffix'.
$form['textfield'] = [
'#type' => 'textfield',
'#prefix' => '<div class="ul">',
'#suffix' => '</div>',
];
I would use the first preferably when I can.