Projet

Général

Profil

Révision 8c72e82a

Ajouté par Assos Assos il y a environ 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform/components/grid.inc
366 366
 *   An array of options to be used for this row.
367 367
 * @return array
368 368
 *   The $row_options with any missing options replaced with empty values.
369
 **/
369
 */
370 370
function webform_grid_remove_options($header, $row_options) {
371 371
  foreach ($header as $key => $value) {
372 372
    if (!isset($row_options[$key])) {
......
498 498
        $value = drupal_render($element[$question_key]);
499 499
      }
500 500
      $items[] = ' - ' . _webform_grid_question_header($question_element['#title']) . ': ' . $value;
501
   }
501
    }
502 502
    $output = implode("\n", $items);
503 503
  }
504 504

  
......
646 646
  // Grids may contain nested multiple value select components.
647 647
  // Create a flat array of values.
648 648
  $values = array();
649
  array_walk_recursive($element['#value'], function($a) use (&$values) { $values[] = $a; });
649
  $element['#value'] = (array) $element['#value'];
650
  array_walk_recursive($element['#value'], function ($a) use (&$values) { $values[] = $a; });
650 651

  
651 652
  $nr_unique = count(array_unique($values));
652 653
  $nr_values = count($values);
......
795 796
    foreach ($element['#parents'] as $key) {
796 797
      $values = isset($values[$key]) ? $values[$key] : $values;
797 798
    }
798
    $nr_values = array_reduce($values, function($count, $item) { return $count + (int)!is_null($item); }, 0);
799
    if (count($element['#grid_questions']) != $nr_values) {
800
      form_error($element, t('!name field is required.', array('!name' => $element['#title'])));
799
    // Remove any values that aren't grid question (i.e. nested components)
800
    $grid_questions = $element['#grid_questions'];
801
    $values = array_intersect_key($values, $grid_questions);
802
    // Remove any unanswered grid questions.
803
    $answers = array_filter($values, function($item) { return !is_null($item); });
804
    // Give required errors for any questions that aren't answered.
805
    foreach (array_diff_key($grid_questions, $answers) as $question_key => $question) {
806
      form_error($element[$question_key], t('!question field within !name is required.', array('!question' => $question, '!name' => $element['#title'])));
801 807
    }
802 808
  }
803 809
}

Formats disponibles : Unified diff