3

I am creating a button using php pear.

Button (php code)

 $this->addButtons(array(
  /**
   * Array for 'next' button
   */
    array(
    'type' => 'next',
    'name' => E::ts('Next'),
    'isDefault' => TRUE,
  ));

Template code

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

I want to add a id attribute to that

1 Answer 1

6

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

$this->addButtons([[
  'type' => 'next',
  'name' => E::ts('Next'),
  'isDefault' => TRUE,
  'class' => 'custom_class', //adding class for button
));

HTH

Pradeep

3
  • I want to set a id attribute. Eg <button id="next" />
    – deepak
    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'); Jan 24, 2019 at 17:48
  • I tried it but not working.
    – deepak
    Feb 26, 2019 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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