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.

1 Answer 1

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 and acknowledge you have read our privacy policy.

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