Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
todoist_api
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
todoist_api
Commits
f59a27c7
Commit
f59a27c7
authored
3 months ago
by
Arjun Kumar
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3486543
: Update cancel button functionality for add and update task.
parent
3b85ca2c
No related branches found
No related tags found
1 merge request
!16
Issue #3486543: Update cancel button functionality for add and update task.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Form/AddTaskForm.php
+9
-2
9 additions, 2 deletions
src/Form/AddTaskForm.php
with
9 additions
and
2 deletions
src/Form/AddTaskForm.php
+
9
−
2
View file @
f59a27c7
...
...
@@ -70,7 +70,7 @@ class AddTaskForm extends FormBase {
$form
[
'actions'
][
'reset'
]
=
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'
Reset
'
),
'#value'
=>
$this
->
t
(
'
Cancel
'
),
'#button_type'
=>
'secondry'
,
];
return
$form
;
...
...
@@ -88,19 +88,26 @@ class AddTaskForm extends FormBase {
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$current_path
=
\Drupal
::
service
(
'path.current'
)
->
getPath
();
$uri
=
'tasks'
;
$message
=
$this
->
t
(
'A new task has been created.'
);
$body
=
[
"content"
=>
$form_state
->
getValue
(
'task'
),
"description"
=>
$form_state
->
getValue
(
'task_description'
),
"due_string"
=>
$form_state
->
getValue
(
'task_due_data'
),
];
try
{
if
(
$form_state
->
getValue
(
'op'
)
==
'Cancel'
){
return
$form_state
->
setRedirect
(
'todoist_api.taskscontroller'
);
}
if
(
preg_match
(
'/\bedit\b/'
,
$current_path
))
{
$body
[
'type'
]
=
'edit'
;
$id
=
\Drupal
::
request
()
->
get
(
'id'
);
$message
=
$this
->
t
(
'A task has been updated.'
);
}
$response
=
\Drupal
::
service
(
'todoist_api.client'
)
->
post
(
$uri
,
$body
,
$id
);
if
(
$response
)
:
$this
->
messenger
()
->
addStatus
(
$
this
->
t
(
'A new task has been created.'
)
);
$this
->
messenger
()
->
addStatus
(
$
message
);
$form_state
->
setRedirect
(
'todoist_api.taskscontroller'
);
endif
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment