Fix error when customized ID is not selected
This commit is contained in:
parent
783affb73a
commit
03c480e32e
@ -56,17 +56,18 @@ 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;
|
||||||
$receiveNewComments = isset($_POST['receiveNewComments']) ? $inputService->filterBoolean($_POST['receiveNewComments']) : false;
|
$receiveNewComments = isset($_POST['receiveNewComments']) ? $inputService->filterBoolean($_POST['receiveNewComments']) : false;
|
||||||
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
|
$hidden = isset($_POST['hidden']) ? $inputService->filterBoolean($_POST['hidden']) : false;
|
||||||
$use_password = filter_input(INPUT_POST, 'use_password', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
$use_password = filter_input(INPUT_POST, 'use_password', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||||
$password = isset($_POST['password'])?$_POST['password']:null;
|
$password = isset($_POST['password']) ? $_POST['password'] : null;
|
||||||
$password_repeat = isset($_POST['password_repeat'])?$_POST['password_repeat']:null;
|
$password_repeat = isset($_POST['password_repeat']) ? $_POST['password_repeat'] : null;
|
||||||
$results_publicly_visible = filter_input(INPUT_POST, 'results_publicly_visible', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
$results_publicly_visible = filter_input(INPUT_POST, 'results_publicly_visible', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => BOOLEAN_REGEX]]);
|
||||||
|
|
||||||
// On initialise également les autres variables
|
// On initialise également les autres variables
|
||||||
@ -100,11 +101,13 @@ if ($goToStep2) {
|
|||||||
$error_on_title = true;
|
$error_on_title = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($id === false) {
|
if ($customizeId) {
|
||||||
$error_on_id = true;
|
if ($id === false) {
|
||||||
} else if ($pollRepository->existsById($id)) {
|
$error_on_id = true;
|
||||||
$error_on_id = true;
|
} else if ($pollRepository->existsById($id)) {
|
||||||
$error_on_id_msg = __('Error', 'Poll id already used');
|
$error_on_id = true;
|
||||||
|
$error_on_id_msg = __('Error', 'Poll id already used');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name !== $_POST['name']) {
|
if ($name !== $_POST['name']) {
|
||||||
|
@ -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