diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-01-14 14:29:44 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-01-14 14:29:44 -0500 |
commit | c6b9c726269a0814dfeac9d26c21e77cf41d847e (patch) | |
tree | bfb10bf6b28c3b1a47c0190e02731794d9f10b70 | |
parent | 2cac4c811d5e7f278d4fa24239cda47b984f15ca (diff) |
Improve external link form when validation fail
-rw-r--r-- | app/Controller/TaskExternalLinkController.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/app/Controller/TaskExternalLinkController.php b/app/Controller/TaskExternalLinkController.php index 9c04eb00..df23f87b 100644 --- a/app/Controller/TaskExternalLinkController.php +++ b/app/Controller/TaskExternalLinkController.php @@ -76,12 +76,23 @@ class TaskExternalLinkController extends BaseController $values = $this->request->getValues(); list($valid, $errors) = $this->externalLinkValidator->validateCreation($values); - if ($valid && $this->taskExternalLinkModel->create($values) !== false) { - $this->flash->success(t('Link added successfully.')); - return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + if ($valid) { + if ($this->taskExternalLinkModel->create($values) !== false) { + $this->flash->success(t('Link added successfully.')); + } else { + $this->flash->success(t('Unable to create your link.')); + } + + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true); + } else { + $provider = $this->externalLinkManager->getProvider($values['link_type']); + $this->response->html($this->template->render('task_external_link/create', array( + 'values' => $values, + 'errors' => $errors, + 'dependencies' => $provider->getDependencies(), + 'task' => $task, + ))); } - - return $this->edit($values, $errors); } /** |