Skip to content
Snippets Groups Projects
Commit 5210a565 authored by Roberto Peruzzo's avatar Roberto Peruzzo
Browse files

Issue #3270497 by robertoperuzzo, nessunluogo: enable textarea in config...

parent a3e84398
Branches
Tags
1 merge request!21Issue #3270497 by robertoperuzzo, nessunluogo: enable textarea in config...
......@@ -16,20 +16,19 @@ iubenda_integration.settings:
iubenda_integration_forms:
type: string
iubenda_integration_pretext:
type: text
label: 'Link prefix'
weight: 1
iubenda_integration_text:
type: label
label: 'Pre-Text'
label: 'Link text'
weight: 2
iubenda_integration_posttext:
type: label
label: 'Post-Text'
iubenda_integration_block_pretext:
type: string
iubenda_integration_block_posttext:
type: string
type: text
label: 'Link suffix'
weight: 3
iubenda_integration_cookie_policy_enabled:
type: boolean
iubenda_integration_text:
type: label
label: 'Link Text'
localConsentPath:
type: string
consentOnScroll:
......
......@@ -45,10 +45,20 @@ function iubenda_integration_form_alter(&$form, FormStateInterface &$form_state,
return;
}
// Set the privacy checkbox as the last but one submit element.
$weight = 1;
$element_types = ['checkbox', 'selectbox', 'item'];
foreach($form as $item) {
if (isset($item['#type']) && in_array($item['#type'], $element_types)) {
$weight++;
}
}
$form['iubenda_integration_privacy_policy'] = [
'#type' => \Drupal::config('iubenda_integration.settings')->get('iubenda_integration_form_element_type'),
'#title' => iubenda_integration_build_string(),
'#required' => TRUE,
'#weight' => $weight,
];
}
......
services:
# The logger service.
logger.channel.iubenda_integration:
class: Drupal\Core\Logger\LoggerChannel
factory: logger.factory:get
arguments: [ 'iubenda_integration' ]
# Subscribers.
iubenda_integration.cookies_event_subscriber:
class: Drupal\iubenda_integration\EventSubscriber\IubendaEventSubscriber
arguments: ['@current_user', '@url_generator', '@renderer']
......
......@@ -96,34 +96,32 @@ class IubendaSettingsForm extends ConfigFormBase {
];
$form['form']['iubenda_integration_forms'] = [
'#title' => $this->t('Privacy Policy Forms'),
'#description' => $this->t('Insert here, one per line, a list of form ids for
which Iubenda Privacy Policy have to be displayed.'),
'#description' => $this->t('Insert here the form ids list (one per line)
where you need to apply the Iubenda Privacy Policy.'),
'#type' => 'textarea',
'#default_value' => $iubenda_config->get('iubenda_integration_forms'),
];
$form['form']['text'] = [
'#title' => $this->t('Text'),
'#title' => $this->t('Privacy Policy link'),
'#type' => 'fieldset',
];
$form['form']['text']['iubenda_integration_pretext'] = [
'#title' => $this->t('Pre-Text'),
'#description' => t('Insert text of the Privacy Policy line have to
precede Iubenda link'),
'#type' => 'textarea',
'#title' => $this->t('Link prefix'),
'#description' => $this->t('Insert the text before the Privacy Policy link.'),
'#default_value' => $iubenda_config->get('iubenda_integration_pretext'),
];
$form['form']['text']['iubenda_integration_text'] = [
'#title' => $this->t('Link Text'),
'#description' => t('Insert text that will be displayed as link'),
'#title' => $this->t('Link text'),
'#description' => $this->t('Insert text that will be displayed as the link.'),
'#type' => 'textfield',
'#default_value' => $iubenda_config->get('iubenda_integration_text'),
'#required' => TRUE,
];
$form['form']['text']['iubenda_integration_posttext'] = [
'#title' => $this->t('Post-Text'),
'#description' => t('Insert text of the Privacy Policy line have to follow
Iubenda link'),
'#type' => 'textarea',
'#title' => $this->t('Link suffix'),
'#description' => $this->t('Insert the text after the Privacy Policy link.'),
'#default_value' => $iubenda_config->get('iubenda_integration_posttext'),
];
......@@ -136,9 +134,8 @@ class IubendaSettingsForm extends ConfigFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
// Save settings.
foreach ($form_state->getValues() as $key => $value) {
//drupal_set_message($key . ': ' . $value);
$this->config('iubenda_integration.settings')
->set($key, $form_state->getValue($key))
->set($key, $value)
->save();
}
......
......@@ -23,7 +23,7 @@ class PrivacyPolicy extends BlockBase {
'iubenda_integration_block' =>
[
'text_prefix' => '',
'text' => 'Privacy Policy',
'text' => $this->t('Privacy policy'),
'text_suffix' => '',
]
];
......@@ -38,29 +38,28 @@ class PrivacyPolicy extends BlockBase {
$form['iubenda_integration_block'] = [
'#type' => 'fieldset',
'#title' => t('Iubenda Privacy settings'),
'#title' => $this->t('Iubenda privacy policy settings'),
];
$form['iubenda_integration_block']['text_prefix'] = [
'#title' => t('Text prefix'),
'#description' => t('Insert text of the Privacy Policy line have to
precede Iubenda link'),
'#type' => 'textarea',
'#title' => $this->t('Link prefix'),
'#description' => $this->t('Insert the text before the Privacy Policy link.'),
'#default_value' => $configurations_iubenda['text_prefix'],
];
$form['iubenda_integration_block']['text'] = [
'#title' => t('Link Text'),
'#description' => t('Insert text that will be displayed as link'),
'#type' => 'textfield',
'#title' => $this->t('Link text'),
'#description' => $this->t('Insert text that will be displayed as the link.'),
'#default_value' => $configurations_iubenda['text'],
'#required' => TRUE,
];
$form['iubenda_integration_block']['text_suffix'] = [
'#title' => t('Text Suffix'),
'#description' => t('Insert text of the Privacy Policy line have to follow
Iubenda link'),
'#type' => 'textarea',
'#title' => $this->t('Link suffix'),
'#description' => $this->t('Insert the text after the Privacy Policy link.'),
'#default_value' => $configurations_iubenda['text_suffix'],
];
return $form;
}
......
......@@ -15,5 +15,5 @@
*/
#}
<div{{ attributes }}>
<p>{{ pre_text }}{{ link }}{{ post_text }}</p>
</div>
\ No newline at end of file
{{ pre_text|raw }}{{ link }}{{ post_text|raw }}
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment