Over a million developers have joined DZone.

CiviCRM change QuickForm Cancel button's value

QuickForm automatically creates the Cancel button as part of the buttons array.  Use this code in the .php controller code if you want to change the HTML value of the button.  Note that the generated HTML uses <input> and not <button>, so the label and the value will be identical.
// Get the buttons array, find the Cancel button, change the label
$new_buttons_obj = $this->getElement('buttons');
foreach ($new_buttons_obj->_elements as $e) {
    if ($e->_attributes['value']=='Cancel') {
        $e->setValue('Cancel and return to previous page');

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}