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

Tricky to set a type on elements within a named group inside repeated elements (backport of MDL-39579)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.9, 2.3.6, 2.4.3
    • Fix Version/s: 2.3.8, 2.4.5
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      Focus on groups within repeated elements

      1. Run the Unit Tests
      2. Play with attached file test_form_validation.php
        • Make sure the warnings displayed are expected
        • Make sure the expected warnings are displayed
        • Make sure the submitted values are cleaned properly
      3. Search for groups in repeated elements
        • Make sure they work as expected
      Show
      Focus on groups within repeated elements Run the Unit Tests Play with attached file test_form_validation.php Make sure the warnings displayed are expected Make sure the expected warnings are displayed Make sure the submitted values are cleaned properly Search for groups in repeated elements Make sure they work as expected
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:

      Description

      The magic in $mform->repeat_elements() does not allow for the developer to set a type on an element within a (named?) group.

      The following code doesn't work:

                  $group = array(
                      $mform->createElement('text', 'repeatedgroupel1', 'repeatedgroupel1'),
                      $mform->createElement('text', 'repeatedgroupel2', 'repeatedgroupel2'));
                  $repeat = $mform->createElement('group', 'mygroup', 'mygroup', $group);
                  $this->repeat_elements(array($repeat), 2, array('mygroup[repeatedgroupel1]' => array('type' => PARAM_INT)),
                      'repeteablegroup', 'add', 0);
      

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            abgreeve Adrian Greeve added a comment -

            Hello Fred,

            The main code here is the same as in master. Testing doesn't provide any problems. Unit tests pass. This all looks good.

            Thanks.

            Show
            abgreeve Adrian Greeve added a comment - Hello Fred, The main code here is the same as in master. Testing doesn't provide any problems. Unit tests pass. This all looks good. Thanks.
            Hide
            fred Frédéric Massart added a comment -

            Cheers!

            Show
            fred Frédéric Massart added a comment - Cheers!
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment - - edited

            Status: accepted (before completing votes!)

            Marina Dan Dam Elo Sam Dev God Outcome
            Y
            Y
            Y
            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - - edited Status: accepted (before completing votes!) Marina Dan Dam Elo Sam Dev God Outcome Y Y Y
            Hide
            marina Marina Glancy added a comment -

            Thanks, it has been integrated in 2.3 and 2.4

            Show
            marina Marina Glancy added a comment - Thanks, it has been integrated in 2.3 and 2.4
            Hide
            phalacee Jason Fowler added a comment -

            Works fine Fred, thanks for the patch

            Show
            phalacee Jason Fowler added a comment - Works fine Fred, thanks for the patch
            Hide
            poltawski Dan Poltawski added a comment -

            Thanks for your contributions!

            _main:
            @ BB#0:
                    push    {r7, lr}
                    mov     r7, sp
                    sub     sp, #4
                    movw    r0, :lower16:(L_.str-(LPC0_0+4))
                    movt    r0, :upper16:(L_.str-(LPC0_0+4))
            LPC0_0:
                    add     r0, pc
                    bl      _printf
                    movs    r1, #0
                    movt    r1, #0
                    str     r0, [sp]                @ 4-byte Spill
                    mov     r0, r1
                    add     sp, #4
                    pop     {r7, pc}
             
                    .section        __TEXT,__cstring,cstring_literals
            L_.str:                                 @ @.str
                    .asciz   "This code is now upstream!"
            

            Show
            poltawski Dan Poltawski added a comment - Thanks for your contributions! _main: @ BB#0: push {r7, lr} mov r7, sp sub sp, #4 movw r0, :lower16:(L_.str-(LPC0_0+4)) movt r0, :upper16:(L_.str-(LPC0_0+4)) LPC0_0: add r0, pc bl _printf movs r1, #0 movt r1, #0 str r0, [sp] @ 4-byte Spill mov r0, r1 add sp, #4 pop {r7, pc}   .section __TEXT,__cstring,cstring_literals L_.str: @ @.str .asciz "This code is now upstream!"

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  8/Jul/13