Skip to content

Commit

Permalink
feat(requesttypefield): allow empty value
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Nov 19, 2020
1 parent 0ccf807 commit 30c86ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions inc/field/requesttypefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use Html;
use Session;
use Ticket;

use Dropdown;
class RequestTypeField extends SelectField
{
public function getDesignSpecializationField() {
Expand All @@ -55,6 +55,9 @@ public function getDesignSpecializationField() {
'value' => $this->value,
'rand' => $rand,
'display' => false,
'toadd' => [
0 => Dropdown::EMPTY_VALUE,
],
]
);
$additions .= '</td>';
Expand All @@ -70,7 +73,7 @@ public function getDesignSpecializationField() {
'label' => $label,
'field' => $field,
'additions' => $additions,
'may_be_empty' => false,
'may_be_empty' => true,
'may_be_required' => true,
];
}
Expand All @@ -85,11 +88,17 @@ public function getRenderedHtml($canEdit = true) {
$rand = mt_rand();
$fieldName = 'formcreator_field_' . $id;

$html .= Ticket::dropdownType($fieldName, [
$options = [
'value' => $this->value,
'rand' => $rand,
'display' => false,
]);
];
if ($this->question->fields['show_empty'] != '0' ) {
$options['toadd'] = [
0 => Dropdown::EMPTY_VALUE,
];
}
$html .= Ticket::dropdownType($fieldName, $options);
$html .= PHP_EOL;
$html .= Html::scriptBlock("$(function() {
pluginFormcreatorInitializeRequestType('$fieldName', '$rand');
Expand Down

0 comments on commit 30c86ae

Please sign in to comment.