Fix error when customized ID is not selected
This commit is contained in:
parent
783affb73a
commit
03c480e32e
@ -56,9 +56,10 @@ if (isset($_GET['type']) && $_GET['type'] == 'date' ||
|
|||||||
$goToStep2 = filter_input(INPUT_POST, GO_TO_STEP_2, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(date|classic)$/']]);
|
$goToStep2 = filter_input(INPUT_POST, GO_TO_STEP_2, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(date|classic)$/']]);
|
||||||
if ($goToStep2) {
|
if ($goToStep2) {
|
||||||
$title = $inputService->filterTitle($_POST['title']);
|
$title = $inputService->filterTitle($_POST['title']);
|
||||||
$id = $inputService->filterId($_POST['id']);
|
$customizeId = $inputService->filterBoolean($_POST['customize_id']);
|
||||||
|
$id = $customizeId == true ? $inputService->filterId($_POST['id']) : null;
|
||||||
$name = $inputService->filterName($_POST['name']);
|
$name = $inputService->filterName($_POST['name']);
|
||||||
$mail = $inputService->filterMail($_POST['mail']);
|
$mail = $config['use_smtp'] == true ? $inputService->filterMail($_POST['mail']) : null;
|
||||||
$description = $inputService->filterDescription($_POST['description']);
|
$description = $inputService->filterDescription($_POST['description']);
|
||||||
$editable = $inputService->filterEditable($_POST['editable']);
|
$editable = $inputService->filterEditable($_POST['editable']);
|
||||||
$receiveNewVotes = isset($_POST['receiveNewVotes']) ? $inputService->filterBoolean($_POST['receiveNewVotes']) : false;
|
$receiveNewVotes = isset($_POST['receiveNewVotes']) ? $inputService->filterBoolean($_POST['receiveNewVotes']) : false;
|
||||||
@ -100,12 +101,14 @@ if ($goToStep2) {
|
|||||||
$error_on_title = true;
|
$error_on_title = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($customizeId) {
|
||||||
if ($id === false) {
|
if ($id === false) {
|
||||||
$error_on_id = true;
|
$error_on_id = true;
|
||||||
} else if ($pollRepository->existsById($id)) {
|
} else if ($pollRepository->existsById($id)) {
|
||||||
$error_on_id = true;
|
$error_on_id = true;
|
||||||
$error_on_id_msg = __('Error', 'Poll id already used');
|
$error_on_id_msg = __('Error', 'Poll id already used');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($name !== $_POST['name']) {
|
if ($name !== $_POST['name']) {
|
||||||
$error_on_name = true;
|
$error_on_name = true;
|
||||||
|
@ -37,15 +37,15 @@ $(document).ready(function () {
|
|||||||
* Enable/Disable custom id options
|
* Enable/Disable custom id options
|
||||||
*/
|
*/
|
||||||
var $pollId = $("#poll_id");
|
var $pollId = $("#poll_id");
|
||||||
var $customId = $("#custom_id");
|
var $customizeId = $("#customize_id");
|
||||||
|
|
||||||
// Init checkbox + input
|
// Init checkbox + input
|
||||||
if (($pollId.val() || $pollId.attr('value') || "").length > 0) {
|
if (($pollId.val() || $pollId.attr('value') || "").length > 0) {
|
||||||
$customId.attr('checked', 'checked');
|
$customizeId.attr('checked', 'checked');
|
||||||
$pollId.removeAttr("disabled");
|
$pollId.removeAttr("disabled");
|
||||||
}
|
}
|
||||||
// Listen for checkbox changes
|
// Listen for checkbox changes
|
||||||
$customId.change(function () {
|
$customizeId.change(function () {
|
||||||
if ($(this).prop("checked")) {
|
if ($(this).prop("checked")) {
|
||||||
$pollId
|
$pollId
|
||||||
.removeAttr("disabled")
|
.removeAttr("disabled")
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon">
|
<span class="input-group-addon">
|
||||||
<input id="custom_id" type="checkbox"/>
|
<input id="customize_id" name="customize_id" type="checkbox"/>
|
||||||
</span>
|
</span>
|
||||||
<input id="poll_id" type="text" name="id" class="form-control" {$errors['id']['aria']}
|
<input id="poll_id" type="text" name="id" class="form-control" {$errors['id']['aria']}
|
||||||
value="{$poll_id}" aria-describedBy="pollIdDesc" disabled="disabled" maxlength="64"
|
value="{$poll_id}" aria-describedBy="pollIdDesc" disabled="disabled" maxlength="64"
|
||||||
|
Loading…
Reference in New Issue
Block a user