Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-59740

Allow submit buttons other than 'cancel' to be secondary

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Put the following code into a .php file and place it in your wwwroot.

        <?php
         
        require_once('config.php');
        require_once($CFG->libdir . '/formslib.php');
         
        $PAGE->set_context(context_system::instance());
        $PAGE->set_url('/');
         
        class test_form extends moodleform {
         
            public function definition() {
                $mform =& $this->_form;
         
                $mform->addElement('submit', '1', 'Should be primary');
                $mform->addElement('submit', 'cancel', 'Should be secondary');
                $mform->addElement('submit', 'cancel', 'Should be primary', array(), true);
                $mform->addElement('submit', 'cancel', 'Should be secondary', array(), false);
                $mform->addElement('submit', 'boo', 'Should be secondary', array(), false);
                $mform->addElement('submit', 'boo1', 'Should be primary', array(), true);
            }
        }
         
        $a = new test_form();
         
        echo $OUTPUT->header();
        echo $a->display();
        echo $OUTPUT->footer();
        

      2. Confirm the buttons are styled the way their name suggests.
      Show
      Put the following code into a .php file and place it in your wwwroot. <?php   require_once('config.php'); require_once($CFG->libdir . '/formslib.php');   $PAGE->set_context(context_system::instance()); $PAGE->set_url('/');   class test_form extends moodleform {   public function definition() { $mform =& $this->_form;   $mform->addElement('submit', '1', 'Should be primary'); $mform->addElement('submit', 'cancel', 'Should be secondary'); $mform->addElement('submit', 'cancel', 'Should be primary', array(), true); $mform->addElement('submit', 'cancel', 'Should be secondary', array(), false); $mform->addElement('submit', 'boo', 'Should be secondary', array(), false); $mform->addElement('submit', 'boo1', 'Should be primary', array(), true); } }   $a = new test_form();   echo $OUTPUT->header(); echo $a->display(); echo $OUTPUT->footer(); Confirm the buttons are styled the way their name suggests.
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-59740_master

      Description

      There is a hardcoded check that only sets 'cancel' submit buttons in mforms as 'btn-secondary'. This is not good as there are places in Moodle where we have multiple primary buttons on a form (example adding an activity). This is also bad for third party developers, who may have multiple submit buttons, which all appear as primary making the form look unattractive and confusing. We can not assume only 'cancel' will be the secondary button.

        Attachments

          Activity

            People

            • Assignee:
              markn Mark Nelson
              Reporter:
              markn Mark Nelson
              Peer reviewer:
              cameron1729
              Integrator:
              Jun Pataleta
              Tester:
              David Monllaó
              Participants:
              Component watchers:
              Jake Dallimore, Jun Pataleta, Bas Brands, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Sep/17