/** * Render a simple state list * * @author jseros, Patrick Kohl * * @param int $stateID Selected state id * @param int $countryID Selected country id * @param string $dependentField Parent <select /> ID attribute * @param string $_prefix Optional prefix for the formtag name attribute * @return string HTML containing the <select /> */ public static function renderStateList($stateId = '0', $_prefix = '', $multiple = FALSE, $required = 0) { if (is_array($stateId)) { $stateId = implode(",", $stateId); } vmJsApi::JcountryStateList($stateId, $_prefix); if ($multiple) { $attrs = 'multiple="multiple" size="12" name="' . $_prefix . 'virtuemart_state_id[]" '; //$class = 'class="inputbox multiple"'; } else { /*$app = JFactory::getApplication(); if($app->isSite()) { $class = 'class="chzn-select"'; } else { $class = 'class="inputbox multiple"'; }*/ $attrs = 'name="' . $_prefix . 'virtuemart_state_id" '; } if ($required != 0) { $attrs .= ' required'; } $attrs .= ' class="vm-chzn-select"'; $listHTML = '<select id="' . $_prefix . 'virtuemart_state_id" ' . $attrs . '> <option value="">' . JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option> </select>'; return $listHTML; }
/** * Render a simple state list * * @author Patrick Kohl * NOte Patrick Kohl added unique ID, javascript is broken if you have 2 lists * @param int $stateID Selected state id * @param int $countryID Selected country id * @param string $dependentField Parent <select /> ID attribute * @param string $_prefix Optional prefix for the formtag name attribute * @return string HTML containing the <select /> */ public static function renderStateList($stateId = '0', $prefix = '', $multiple = FALSE, $required = 0) { $id = $prefix . 'virtuemart_state_id'; // prevent using same ID, in all case this break the sate render if id is same. static $keys = array(); if (isset($keys[$id])) { return; } $keys[$id] = true; if (is_array($stateId)) { $stateId = implode(",", $stateId); } vmJsApi::JcountryStateList($stateId, $prefix); if ($multiple) { $attrs = 'multiple="multiple" size="12" name="' . $id . '[]" '; //$class = 'class="inputbox multiple"'; } else { $attrs = 'size="1" name="' . $id . '" '; } if ($required != 0) { $attrs .= ' required'; } $class = 'class="inputbox multiple"'; $listHTML = '<select ' . $class . ' id="' . $id . '" ' . $attrs . '> <option value="">' . JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option> </select>'; return $listHTML; }
/** * Render a simple state list * * @author Valerie Isaksen, Max Milbers * * @param int $stateID Selected state id * @param int $countryID Selected country id * @param string $dependentField Parent <select /> ID attribute * @param string $_prefix Optional prefix for the formtag name attribute * @return string HTML containing the <select /> */ public static function renderStateList($stateId = '0', $_prefix = '', $multiple = FALSE, $required = 0, $attribs = array()) { if (is_array($stateId)) { $stateId = implode(",", $stateId); } vmJsApi::JcountryStateList($stateId, $_prefix); $attrs['class'] = 'vm-chzn-select'; if ($multiple) { $attrs['name'] = $_prefix . 'virtuemart_state_id[]'; $attrs['multiple'] = 'multiple'; } else { $attrs['name'] = $_prefix . 'virtuemart_state_id'; } /*if ($required != 0) { $attrs['class'] .= ' required '; }*/ if (is_array($attribs)) { $attrs = array_merge($attrs, $attribs); } $attrString = JArrayHelper::toString($attrs); $listHTML = '<select id="' . $_prefix . 'virtuemart_state_id" ' . $attrString . '> <option value="">' . JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option> </select>'; return $listHTML; }
/** * Render a simple state list * * @author jseros, Patrick Kohl * * @param int $stateID Selected state id * @param int $countryID Selected country id * @param string $dependentField Parent <select /> ID attribute * @param string $_prefix Optional prefix for the formtag name attribute * @return string HTML containing the <select /> */ public static function renderStateList($stateId = '0', $_prefix = '', $multiple = FALSE, $required = 0) { if (is_array($stateId)) { $stateId = implode(",", $stateId); } vmJsApi::JcountryStateList($stateId); if ($multiple) { $attrs = 'multiple="multiple" size="12" name="' . $_prefix . 'virtuemart_state_id[]" '; } else { $attrs = 'size="1" name="' . $_prefix . 'virtuemart_state_id" '; } if ($required != 0) { $attrs .= ' required'; } $listHTML = '<select class="inputbox multiple" id="virtuemart_state_id" ' . $attrs . '> <option value="">' . JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . '</option> </select>'; return $listHTML; }