DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

J has posted 6 posts at DZone. View Full User Profile

CiviCRM change QuickForm Cancel button's value

  • submit to reddit
// 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');
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.