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

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

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

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.