Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Telenkov Ruslan
new_project
Commits
6558fd45
Commit
6558fd45
authored
Jun 06, 2022
by
Telenkov Ruslan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this is modal window task
parent
3f784168
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
3 deletions
+41
-3
formApi.module
app/docroot/modules/custom/formApi/formApi.module
+31
-0
FormApiTask.php
app/docroot/modules/custom/formApi/src/Form/FormApiTask.php
+6
-2
form-theme.html.twig
...oot/modules/custom/formApi/templates/form-theme.html.twig
+3
-0
myservice.module
app/docroot/modules/custom/myservice/myservice.module
+1
-1
No files found.
app/docroot/modules/custom/formApi/formApi.module
0 → 100644
View file @
6558fd45
<?php
/**
* Implements hook_theme().
*/
function
formApi_theme
(
$existing
,
$type
,
$theme
,
$path
)
{
return
[
'form_theme'
=>
[
'variables'
=>
[],
],
];
}
/**
* Implements template_preprocess_HOOK().
* Обработчик переменных для первого примера.
*/
function
template_preprocess_form_theme
(
&
$variables
)
{
$myConfigPage
=
\Drupal\config_pages\Entity\ConfigPages
::
config
(
'custom_config'
);
$variables
[
'string_modal'
]
=
$myConfigPage
->
get
(
'field_modal_title'
)
->
value
;
$current_user
=
\Drupal
::
currentUser
();
$user
=
\Drupal\user\Entity\User
::
load
(
$current_user
->
id
());
$name
=
$user
->
get
(
'name'
)
->
value
;
$user_last_name
=
$user
->
field_last_name
->
value
;
if
(
$name
==
NULL
){
$variables
[
'result'
]
=
$variables
[
'string_modal'
]
.
", гость!"
;
}
else
{
$variables
[
'result'
]
=
$variables
[
'string_modal'
]
.
', '
.
$user_last_name
.
' '
.
$name
;
}
}
app/docroot/modules/custom/formApi/src/Form/FormApiTask.php
View file @
6558fd45
...
@@ -14,7 +14,7 @@ use Drupal\Core\Ajax\RedirectCommand;
...
@@ -14,7 +14,7 @@ use Drupal\Core\Ajax\RedirectCommand;
use
Drupal\Core\Ajax\RemoveCommand
;
use
Drupal\Core\Ajax\RemoveCommand
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Ajax\OpenModalDialogCommand
;
class
FormApiTask
extends
FormBase
{
class
FormApiTask
extends
FormBase
{
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -189,7 +189,11 @@ class FormApiTask extends FormBase {
...
@@ -189,7 +189,11 @@ class FormApiTask extends FormBase {
])
])
->
execute
();
->
execute
();
$response
->
addCommand
(
new
AlertCommand
(
'Спасибо за заполнение, нажмите "OK" для продолжения'
));
$content1
[
'#attached'
][
'library'
][]
=
'core/drupal.dialog.ajax'
;
$content1
[
'#theme'
]
=
'form_theme'
;
$title
=
'Сообщение'
;
$response
->
addCommand
(
new
OpenModalDialogCommand
(
$title
,
$content1
,
[
'width'
=>
'200'
,
'height'
=>
'200'
]));
//$response->addCommand(new AlertCommand('Спасибо за заполнение, нажмите "OK" для продолжения'));
$url
=
'/'
;
$url
=
'/'
;
$response
->
addCommand
(
new
RedirectCommand
(
$url
));
$response
->
addCommand
(
new
RedirectCommand
(
$url
));
...
...
app/docroot/modules/custom/formApi/templates/form-theme.html.twig
0 → 100644
View file @
6558fd45
<div
style=
"color:blue"
>
{{
result
}}
</div>
app/docroot/modules/custom/myservice/myservice.module
View file @
6558fd45
...
@@ -30,7 +30,7 @@ function myservice_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form
...
@@ -30,7 +30,7 @@ function myservice_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form
if
(
$form_id
==
'contact_message_contact_form_form'
)
{
if
(
$form_id
==
'contact_message_contact_form_form'
)
{
$current_user
=
\Drupal
::
currentUser
();
$current_user
=
\Drupal
::
currentUser
();
$user
=
\Drupal\user\Entity\User
::
load
(
$current_user
->
id
());
$user
=
\Drupal\user\Entity\User
::
load
(
$current_user
->
id
());
$name
=
$user
->
name
->
value
;
$name
=
$user
->
get
(
'name'
)
->
value
;
$user_last_name
=
$user
->
field_last_name
->
value
;
$user_last_name
=
$user
->
field_last_name
->
value
;
$form
[
'field_last_name'
][
'widget'
][
0
][
'value'
][
'#default_value'
]
=
$user_last_name
;
$form
[
'field_last_name'
][
'widget'
][
0
][
'value'
][
'#default_value'
]
=
$user_last_name
;
$form
[
'field_name'
][
'widget'
][
0
][
'value'
][
'#default_value'
]
=
$name
;
$form
[
'field_name'
][
'widget'
][
0
][
'value'
][
'#default_value'
]
=
$name
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment