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

Improve field normalisation and add support for setting fields in a fieldset

    XMLWordPrintable

    Details

      Description

      In some situations we will have fields which have the same name, in different sections of the form.

      This will happen for repeated elements, as well as where we have multiple grading forms on a page.

      It's pretty natural to use the labelled fieldset to distinguish between the different but similar fields on the form. We should support that.

      There are several ways in which we can already do so:

      Then the "Grade to pass" "field" in the "Ratings" "fieldset" should be visible
      Then I should see field "Grade to pass" in the "Ratings" "fieldset"
      

      However, it's not currently possible to interact with them using form steps in a meaningful way.

      I'm proposing the following new format, which will work in all situations:

      Then the "Ratings > Grade to pass" "field" should be visible
      Then I should see field "Ratings > Grade to pass"
      Then I set field "Ratings > Grade to pass" to "40"
      

      In order to do so it seems that we need to simplify the way in which we normalise selectors.
      Right now it happens in two places:

      1. In some cases we call behat_selectors::get_behat_selector; and
      2. In other cases the find_all function did some of the same things.

      So to solve this I have moved the normalisation of behat selectors to behat_base::normalise_selector() which takes the same arguments as get_behat_selector but also takes the $container and returns an associative array containing the combined container, and normalised selector and normalised locator. I've updated everywhere to use this normalisation.

      This means that, going forward, the following exciting things are possible:

      1. I can select fields via their fieldset anywhere that I can specify a standard selector pair (selector + type)
      2. Any other type can do similar magic - i.e. we could define exactly the same kind of logic for a new "breadcrumb" type where it recursively finds the container depending on how many times the ">" character is used

      It may also have additional uses in the future - I'm thinking for things like MDL-66335 and similar.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Nov/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 days, 3 hours, 56 minutes
                  2d 3h 56m