/**
	 * Method to build the list for types when performing an edit action
	 *
	 * @return array
	 * @since 1.5
	 */
	static function buildfieldtypeslist($name, $class, $selected, $group=false)
	{
		$field_types = flexicontent_db::getfieldtypes($group);
		if (!$group) {
			// This should not be neccessary as, it was already done in DB query above
			foreach($field_types as $field_type) {
				$field_type->text = preg_replace("/FLEXIcontent[ \t]*-[ \t]*/i", "", $field_type->text);
				$field_arr[$field_type->text] = $field_type;
			}
			ksort( $field_arr, SORT_STRING );
			
			$list = JHTML::_('select.genericlist', $field_arr, $name, $class, 'value', 'text', $selected );
		} else {
			$fftype = array();
			foreach ($field_types as $field_group => $ft_types) {
				$fftype[] = JHTML::_('select.optgroup', $field_group );
				foreach ($ft_types as $field_type => $ftdata) {
					$field_friendlyname = preg_replace("/FLEXIcontent[ \t]*-[ \t]*/i", "", $ftdata->text);
					$fftype[] = JHTML::_('select.option', $field_type, $field_friendlyname);
				}
				$fftype[] = JHTML::_('select.optgroup', '' );
			}
			
			$fieldname = FLEXI_J16GE ? 'jform[field_type]' : 'field_type';
			$elementid = FLEXI_J16GE ? 'jform_field_type'  : 'field_type';
			$list = JHTML::_('select.genericlist', $fftype, $fieldname, 'class="inputbox" size="1"', 'value', 'text', $selected, $elementid );
			if (!FLEXI_J16GE) $list = str_replace('<optgroup label="">', '</optgroup>', $list);
		}
		return $list;
	}