function getValueFromArray($name, $params) { if (is_array(ArrayUtility::arrayFromString($name, false))) { $value = ArrayUtility::getArrayValueMulti($params, ArrayUtility::arrayFromString($name)); } else { //$value = ArrayUtility::getArrayValue($params,$name); if (isset($params[$name])) { $value = $params[$name]; } else { $value = ''; } } return $value; }
function generateInputObjects() { $ret = array(); $tabindex_count = 0; foreach ($this->standard_options as $name => $values) { if (isset($values['value'])) { $value = $values['value']; } else { $value = ''; } if (isset($values['label'])) { $label = $values['label']; } else { $label = ''; } if ($this->item_link_class) { $secondary_get_vars = ArrayUtility::merge($this->secondary_get_vars, array($name => $value)); $href = Display::hrefString($this->item_link_class, $secondary_get_vars); $label = new FormLink($href, $label); } else { $label = new FormLabel($label); } switch ($this->type) { case ButtonGroup::CHECK: $obj = new Checkbox($name, $this->class, '', $value, $label, ''); break; case ButtonGroup::RADIO: $obj = new RadioButton($name, $this->class, '', $value, $label, ''); break; case ButtonGroup::NONE: $obj = $label; break; } if ($obj instanceof FormInput) { $obj->setTabindex($this->tabindex + $tabindex_count); } $tabindex_count++; } $selected = $this->selected; $primary_get_string = ''; $check_name = $this->name; if (!$this->options) { $this->options = array(); } foreach ($this->options as $opt) { $cur_check_name = $opt->formOptionName($check_name); $cur_check_value = $opt->formOptionValue(); $cur_check_label = $opt->toString(); $opt->formLinkGetVars($this->secondary_get_vars); $check_selected = ArrayUtility::arrayFromString($cur_check_name, false); if ($this->type == ButtonGroup::CHECK || $this->type == ButtonGroup::NONE) { $cur_check_name .= '[]'; } if ($this->item_link_class) { $href = Display::hrefString($this->item_link_class, $this->secondary_get_vars); $label = new FormLink($href, $cur_check_label); } else { $label = new FormLabel($cur_check_label); } switch ($this->type) { case ButtonGroup::CHECK: if (count($check_selected) && is_array($check_selected)) { $sel_array = ArrayUtility::getArrayValueMulti($selected, $check_selected); if (!is_array($sel_array)) { $sel_array = array(); } } else { $sel_array = $selected; } if (in_array($cur_check_value, $sel_array)) { $is_selected = true; } else { $is_selected = false; } $obj = new Checkbox($cur_check_name, $this->class, '', $cur_check_value, $label, $is_selected); break; case ButtonGroup::RADIO: if ($cur_check_value == $selected) { $is_selected = true; } else { $is_selected = false; } $obj = new RadioButton($cur_check_name, $this->class, '', $cur_check_value, $label, $is_selected); break; case ButtonGroup::NONE: $obj = new HiddenLabel($cur_check_name, $cur_check_value, $label, ''); break; } if ($obj instanceof FormInput) { $obj->setTabindex($this->tabindex + $tabindex_count); } $ret[] = $obj; $tabindex_count++; } return $ret; }