Skip to content

Commit

Permalink
[templates] Updated text_format to get the value (#4035)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjuarez20 authored and enzolutions committed May 14, 2019
1 parent 8b2753d commit 168b250
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion templates/module/src/Form/form-config.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion templates/module/src/Form/form.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
4 changes: 2 additions & 2 deletions templates/module/src/Plugin/Block/block.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
}

Expand All @@ -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 %}
Expand Down

0 comments on commit 168b250

Please sign in to comment.