showing dropdowns for comma separated values

Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/30070413
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/30070413
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/30070413

Branch: refs/heads/dreg-gateway
Commit: 300704135a45f165758f3d9366f7959d666a2d68
Parents: f78c828
Author: scnakandala <supun.nakand...@gmail.com>
Authored: Tue Jul 25 13:31:44 2017 -0400
Committer: scnakandala <supun.nakand...@gmail.com>
Committed: Tue Jul 25 13:31:44 2017 -0400

----------------------------------------------------------------------
 app/libraries/ExperimentUtilities.php | 63 +++++++++++++++++++++++-------
 1 file changed, 48 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/30070413/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php 
b/app/libraries/ExperimentUtilities.php
index 447cd7a..a4efc9d 100755
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -794,27 +794,60 @@ class ExperimentUtilities
             switch ($input->type) {
                 case DataType::STRING:
                     echo '<div class="form-group">
-                    <label for="experiment-input">' . $input->name . '</label>
-                    <input '.$disabled . ' value="' . $input->value . '" 
type="text" class="form-control" name="' . $input->sanitizedFormName .
-                        '" id="' . $input->sanitizedFormName .
-                        '" placeholder="' . $input->userFriendlyDescription . 
'"' . $required . '>
-                    </div>';
+                    <label for="experiment-input">' . $input->name . 
'</label>';
+                    if(!empty($input->value) && count(explode(",", 
$input->value)) > 1){
+                        echo '<select class="form-control" name="' . 
$input->sanitizedFormName .
+                            '" id="' . $input->sanitizedFormName . '">';
+                        $vals = explode(",", $input->value);
+                        echo '<option value="'.$vals[0].'" selected>'.$vals[0] 
.'</option>';
+                        for($i=1; $i<count(explode(",", $input->value)); $i++){
+                            echo '<option value="'.$vals[$i].'"'.$vals[$i] 
.'</option>';
+                        }
+                        echo '</select>';
+                    }else{
+                        echo '<input '.$disabled . ' value="' . $input->value 
. '" type="text" class="form-control" name="' . $input->sanitizedFormName .
+                            '" id="' . $input->sanitizedFormName .
+                            '" placeholder="' . 
$input->userFriendlyDescription . '"' . $required . '>
+                        </div>';
+                    }
                     break;
                 case DataType::INTEGER:
                     echo '<div class="form-group">
-                    <label for="experiment-input">' . $input->name . '</label>
-                    <input '.$disabled . ' value="' . $input->value . '" 
type="number" class="form-control" name="' . $input->sanitizedFormName .
-                        '" id="' . $input->sanitizedFormName .
-                        '" placeholder="' . $input->userFriendlyDescription . 
'"' . $required . '>
-                    </div>';
+                    <label for="experiment-input">' . $input->name . 
'</label>';
+                    if(!empty($input->value) && count(explode(",", 
$input->value)) > 1){
+                        echo '<select class="form-control" name="' . 
$input->sanitizedFormName .
+                            '" id="' . $input->sanitizedFormName . '">';
+                        $vals = explode(",", $input->value);
+                        echo '<option value="'.$vals[0].'" selected>'.$vals[0] 
.'</option>';
+                        for($i=1; $i<count(explode(",", $input->value)); $i++){
+                            echo '<option value="'.$vals[$i].'"'.$vals[$i] 
.'</option>';
+                        }
+                        echo '</select>';
+                    }else{
+                        echo '<input '.$disabled . ' value="' . $input->value 
. '" type="number" class="form-control" name="' . $input->sanitizedFormName .
+                            '" id="' . $input->sanitizedFormName .
+                            '" placeholder="' . 
$input->userFriendlyDescription . '"' . $required . '>
+                            </div>';
+                    }
                     break;
                 case DataType::FLOAT:
                     echo '<div class="form-group">
-                    <label for="experiment-input">' . $input->name . '</label>
-                    <input '.$disabled . ' value="' . $input->value . '" 
type="number" step="0.01" class="form-control" name="' . 
$input->sanitizedFormName .
-                        '" id="' . $input->sanitizedFormName .
-                        '" placeholder="' . $input->userFriendlyDescription . 
'"' . $required . '>
-                    </div>';
+                    <label for="experiment-input">' . $input->name . 
'</label>';
+                    if(!empty($input->value) && count(explode(",", 
$input->value)) > 1){
+                        echo '<select class="form-control" name="' . 
$input->sanitizedFormName .
+                            '" id="' . $input->sanitizedFormName . '">';
+                        $vals = explode(",", $input->value);
+                        echo '<option value="'.$vals[0].'" selected>'.$vals[0] 
.'</option>';
+                        for($i=1; $i<count(explode(",", $input->value)); $i++){
+                            echo '<option value="'.$vals[$i].'"'.$vals[$i] 
.'</option>';
+                        }
+                        echo '</select>';
+                    }else{
+                        echo '<input '.$disabled . ' value="' . $input->value 
. '" type="number" step="0.01" class="form-control" name="' . 
$input->sanitizedFormName .
+                            '" id="' . $input->sanitizedFormName .
+                            '" placeholder="' . 
$input->userFriendlyDescription . '"' . $required . '>
+                        </div>';
+                    }
                     break;
                 case DataType::URI:
                     if(!empty($input->metaData) && 
json_decode($input->metaData)->location == "remote"){

Reply via email to