1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.