Advertisement
NFL

Untitled

NFL
Dec 12th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.24 KB | None | 0 0
  1. foreach ($propertiesList as &$v) {
  2.                     if (in_array($v['type'], array(Core_Input::TYPE_CHECKBOX, Core_Input::TYPE_RADIO, Core_Input::TYPE_SELECT))) {
  3.                         $values = explode(',', $v['default_values']);
  4.                         foreach ($values as $k => $val) {
  5.                             if (!mb_strlen($val)) {
  6.                                 unset($values[$k]);
  7.                             }
  8.                         }
  9.                         if (count($values)) {
  10.                             array_walk($values, function(&$val, $key) {
  11.                                         $val = trim($val);
  12.                                         if (!mb_strlen($val)) {
  13.                                             unset($values[$key]);
  14.                                         }
  15.                                     });
  16.                             switch ($v['type']) {
  17.                                 case Core_Input::TYPE_SELECT:
  18.                                     array_unshift($values, 'Выбрать');
  19.                                     break;
  20.                                 case Core_Input::TYPE_CHECKBOX:
  21.                                     $v['element'] = 'formMultiCheckbox';
  22.                                     break;
  23.                                 case Core_Input::TYPE_RADIO:
  24.                                     //No individual actions
  25.                                     break;
  26.                             }
  27.                             $v['values'] = array_combine(array_values($values), array_values($values));
  28.                         } else {
  29.                             switch ($v['type']) {
  30.                                 case Core_Input::TYPE_RADIO: case Core_Input::TYPE_SELECT:
  31.                                     $v['values'] = array('1' => 'Да', '0' => 'Нет');
  32.                                     break;
  33.                                 case Core_Input::TYPE_CHECKBOX:
  34.                                     $v['values'] = array('Да' => '1');
  35.                                     break;
  36.                             }
  37.                         }
  38.                     }
  39.                     if (!isset($v['element']))
  40.                         $v['element'] = 'form' . ucfirst($v['type']);
  41.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement