BUG 10920 "Add subtitles inside a drop-down" SOLVED

- New feature, add subtitles inside a drop-down
- Solved problem, added grouping elements in DropDowns
- If a DropDown has enabled optgroup, an example with SQL would be the following:
    (SELECT 'optgroup1' AS UID, 'Users' AS NAME)
    UNION
    (SELECT USR.USR_UID AS UID, USR.USR_USERNAME AS NAME
     FROM   USERS AS USR
     WHERE  USR.USR_USERNAME <> '' AND USR.USR_USERNAME LIKE 'u%'
    )
    UNION
    (SELECT 'optgroup2' AS UID, 'Countries' AS NAME)
    UNION
    (SELECT COUNTRY.IC_UID AS UID, COUNTRY.IC_NAME AS NAME
     FROM   ISO_COUNTRY AS COUNTRY
     WHERE  COUNTRY.IC_NAME LIKE 'b%'
    )
* Available from version ProcessMaker-2.0.47 (2.5.1)
This commit is contained in:
Victor Saisa Lopez
2013-03-27 09:57:22 -04:00
parent baca267dff
commit 3cd724a9ed
9 changed files with 531 additions and 309 deletions

View File

@@ -137,7 +137,17 @@ if (! (isset( $fields->Fields['XMLNODE_NAME'] ) && ($fields->Fields['XMLNODE_NAM
if (! is_array( $options ) || count( $options ) == 0) {
$options = array ('' => '' );
}
$Fields['PME_OPTIONS'] = array ('NAME' => array_keys( $options ),'LABEL' => array_values( $options ) );
$arrayOptionName = array_keys($options);
$arrayOptionLabel = array_values($options);
$arrayOptionOptGroup = array();
foreach ($arrayOptionName as $value) {
$arrayOptionOptGroup[] = (preg_match("/^optgroup\d+$/", $value))? 1 : 0;
}
$Fields["PME_OPTIONS"] = array("NAME" => $arrayOptionName, "LABEL" => $arrayOptionLabel, "OPTGROUP" => $arrayOptionOptGroup);
$type = strtolower( $fields->Fields['TYPE'] );
if ($type === 'checkbox') {
if ($Fields['PME_DEFAULTVALUE'] === $Fields['PME_VALUE']) {

View File

@@ -55,6 +55,8 @@ if (isset($_POST['form']['PME_READONLY'])) {
$_POST['form']['PME_READONLY'] = 0;
}
$_POST["form"]["PME_OPTGROUP"] = (isset($_POST["form"]["PME_OPTGROUP"]) && !empty($_POST["form"]["PME_OPTGROUP"]))? intval($_POST["form"]["PME_OPTGROUP"]) : 0;
if (isset($_POST['form']['PME_SAVELABEL'])) {
if ($_POST['form']['PME_SAVELABEL'] == '') {
$_POST['form']['PME_SAVELABEL'] = 0;
@@ -131,6 +133,7 @@ if (file_exists(PATH_XMLFORM . 'dynaforms/fields/' . $type . '.xml')) {
}
}
}
foreach ($_POST['form'] as $key => $value) {
if (substr($key, 0, 4) === 'PME_') {
$res[substr($key, 4)] = $value;
@@ -138,6 +141,7 @@ foreach ($_POST['form'] as $key => $value) {
$res[$key] = $value;
}
}
$_POST['form'] = $res;
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
@@ -261,3 +265,4 @@ if (isset($sType) && $sType === 'javascript') {
$editor = new dynaformEditorAjax($_POST);
$editor->set_javascript($A, $fieldName, $sCode);
}