Skip to content

Commit

Permalink
Merge remote-tracking branch 'stonebuzz/fix_request_type_field' into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
btry committed Feb 4, 2020
2 parents 0780670 + c16c6f9 commit 9f859d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
35 changes: 20 additions & 15 deletions inc/fields/requesttypefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,27 @@ public function getDesignSpecializationField() {
];
}

public function displayField($canEdit = true) {
if ($canEdit) {
$id = $this->question->getID();
$rand = mt_rand();
$fieldName = 'formcreator_field_' . $id;
Ticket::dropdownType($fieldName, [
'value' => $this->value,
'rand' => $rand,
]);
echo PHP_EOL;
echo Html::scriptBlock("$(function() {
pluginFormcreatorInitializeRequestType('$fieldName', '$rand');
});");
} else {
echo Ticket::getTicketTypeName($this->value);
public function getRenderedHtml($canEdit = true) {
$html = "";
if (!$canEdit) {
return Ticket::getTicketTypeName($this->value);
}

$id = $this->question->getID();
$rand = mt_rand();
$fieldName = 'formcreator_field_' . $id;

$html .= Ticket::dropdownType($fieldName, [
'value' => $this->value,
'rand' => $rand,
'display' => false,
]);
$html .= PHP_EOL;
$html .= Html::scriptBlock("$(function() {
pluginFormcreatorInitializeRequestType('$fieldName', '$rand');
});");

return $html;
}

public static function getName() {
Expand Down
2 changes: 1 addition & 1 deletion js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ function pluginFormcreatorInitializeMultiselect(fieldName, rand) {
function pluginFormcreatorInitializeRequestType(fieldName, rand) {
var field = $('select[name="' + fieldName + '"]');
field.on("change", function(e) {
formcreatorShowFields($(field[0].form));
plugin_formcreator.showFields($(field[0].form));
});
}

Expand Down

0 comments on commit 9f859d3

Please sign in to comment.