62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
$options = [];
|
|
if(strpos($item->typedata, "=Model=") !== false) {
|
|
// get options from Model
|
|
$m = [];
|
|
if(preg_match('/^=Model=(\w+)(?::([^:]+):)?$/', $item->typedata, $m)) {
|
|
// dynamic enum
|
|
$model = $m[1];
|
|
$modelClass = $model."Model";
|
|
|
|
if($m[2]) {
|
|
$filter_parts = explode("=", $m[2]);
|
|
$filter_name = $filter_parts[0];
|
|
$filter_value = $filter_parts[1];
|
|
|
|
if(substr($filter_value, 0, 1) == '`') {
|
|
$filter_value = substr($filter_value, 1, strlen($filter_value) - 2);
|
|
$objPath = explode("->", $filter_value);
|
|
|
|
if(count($objPath) > 1) {
|
|
$obj = array_shift($objPath);
|
|
$curr = $$obj;
|
|
foreach($objPath as $part) {
|
|
$curr = $curr->$part;
|
|
}
|
|
$filter_value = $curr;
|
|
}
|
|
}
|
|
|
|
foreach($modelClass::search([$filter_name => $filter_value]) as $modelObject) {
|
|
$options[] = $modelObject->id . "=" . $modelObject->name;
|
|
}
|
|
}
|
|
|
|
}
|
|
} else {
|
|
$options = explode(";", $item->typedata);
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<select class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>_<?=$$wftype->id?>" <?=($item->style) ? "style='".$item->style."'" : ""?>>
|
|
<option <?=($item->style) ? "style='".$item->style."'" : ""?>></option>
|
|
<?php foreach($options as $opt): ?>
|
|
<?php
|
|
$key = $opt;
|
|
$label = $opt;
|
|
if(strpos($opt, "=") !== false) {
|
|
$opt_parts = explode('=', $opt);
|
|
$key = $opt_parts[0];
|
|
$label = $opt_parts[1];
|
|
}
|
|
?>
|
|
|
|
<option
|
|
value="<?=$key?>"
|
|
<?=($key == $item->value->value_string) ? "selected='selected'" : ""?>
|
|
><?=$label?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|