Skip to content
Permalink
Browse files

[templates] Updated text_format to get the value (#4035)

  • Loading branch information...
harold20 authored and enzolutions committed May 14, 2019
1 parent 8b2753d commit 168b2509033595cc5642db74492cdad420468041
@@ -115,7 +115,7 @@ class {{ class_name }} extends ConfigFormBase {% endblock %}

$this->config('{{module_name}}.{{class_name_short}}')
{% for input in inputs %}
->set('{{ input.name }}', $form_state->getValue('{{ input.name }}'))
->set('{{ input.name }}', $form_state->getValue('{{ input.name }}'){% if input.type == 'text_format' %}['value']{% endif %})
{% endfor %}
->save();
}
@@ -115,7 +115,7 @@ class {{ class_name }} extends FormBase {% endblock %}
public function submitForm(array &$form, FormStateInterface $form_state) {
// Display result.
foreach ($form_state->getValues() as $key => $value) {
\Drupal::messenger()->addMessage($key . ': ' . $value);
\Drupal::messenger()->addMessage($key . ': ' . $value{% if input.type == 'text_format' %}['value']{% endif %});
}
}
{% endblock %}
@@ -117,7 +117,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
*/
public function blockSubmit($form, FormStateInterface $form_state) {
{% for input in inputs %}
$this->configuration['{{ input.name }}'] = $form_state->getValue('{{ input.name }}');
$this->configuration['{{ input.name }}'] = $form_state->getValue('{{ input.name }}'){% if input.type == 'text_format' %}['value']{% endif %};
{% endfor %}
}

@@ -128,7 +128,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
public function build() {
$build = [];
{% for input in inputs %}
$build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}'] . '</p>';
$build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}']. '</p>';
{% else %}
$build['{{plugin_id}}']['#markup'] = 'Implement {{class_name}}.';
{% endfor %}

0 comments on commit 168b250

Please sign in to comment.
You can’t perform that action at this time.