Moodle

choosecoursefile form element doesn't work 100% in repeatelements.

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.9.4, 2.0
  • Fix Version/s: STABLE backlog
  • Component/s: Forms Library
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

what gets returned after the form is submitted looks like this:

Array (
[filepath[0]] =>
[filepath[1]] =>
[filepath[2]] =>
)

rather than
Array(
filepath => array
0 =>
1 =>
2 =>
)
)

I guess because the form element appends [value] to the name, so the formname is filepath[0][value]

Activity

Hide
Penny Leach added a comment -

I changed my validation method to accept $data by reference and put the following in which seems to fix it:

$data['filepath'] = array();
foreach (array_keys($data['mediaid']) as $key) { $data['filepath'][$key] = $data['filepath[' . $key . ']']; unset($data['filepath[' . $key . ']']); }

but this should be fixed either in repeat elements or in the form element, not sure which.

Show
Penny Leach added a comment - I changed my validation method to accept $data by reference and put the following in which seems to fix it: $data['filepath'] = array(); foreach (array_keys($data['mediaid']) as $key) { $data['filepath'][$key] = $data['filepath[' . $key . ']']; unset($data['filepath[' . $key . ']']); } but this should be fixed either in repeat elements or in the form element, not sure which.

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated: