I am creating a button using php pear.

Button (php code)

   * Array for 'next' button
    'type' => 'next',
    'name' => E::ts('Next'),
    'isDefault' => TRUE,

Template code

<div class="crm-submit-buttons">
 {include file="CRM/common/formButtons.tpl" location="bottom"}

I want to add a id attribute to that

1 Answer 1


I believe you cannot set id to a button using php however you can define your own class for the button and use JS to set the id for that class.

Here is the snippet to add class for button

  'type' => 'next',
  'name' => E::ts('Next'),
  'isDefault' => TRUE,
  'class' => 'custom_class', //adding class for button



  • I want to set a id attribute. Eg <button id="next" />
    – deepak
    Commented Jan 24, 2019 at 17:21
  • 1
    Yes, But you cannot add id through php it allows you to add class. You can use class in JS to set id for the button $('. custom_class').attr('id', 'next'); Commented Jan 24, 2019 at 17:48
  • I tried it but not working.
    – deepak
    Commented Feb 26, 2019 at 12:11

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.