[CONTROLLER][Feeds] Add block prefixes to distinguish form groups

[TWIG] Divide form into various groupings for clearer representation
This commit is contained in:
Eliseu Amaro 2021-11-29 17:01:08 +00:00 committed by Diogo Peralta Cordeiro
parent c8ba81897c
commit f92c00c7aa
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 41 additions and 15 deletions

View File

@ -2,13 +2,6 @@ input {
all: unset;
}
input+label {
-webkit-align-self: center;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
}
input[type=checkbox],input[type=radio] {
all: unset;
display: inline-block;

View File

@ -147,10 +147,10 @@ class Feeds extends Controller
$form_definitions = [];
foreach ($feeds as $feed) {
$md5 = md5($feed->getUrl());
$form_definitions[] = [$md5 . '-url', TextType::class, ['data' => $feed->getUrl(), 'label' => ' ']];
$form_definitions[] = [$md5 . '-order', IntegerType::class, ['data' => $feed->getOrdering(), 'label' => ' ']];
$form_definitions[] = [$md5 . '-title', TextType::class, ['data' => $feed->getTitle(), 'label' => ' ']];
$form_definitions[] = [$md5 . '-remove', SubmitType::class, ['label' => _m('Remove')]];
$form_definitions[] = [$md5 . '-url', TextType::class, ['data' => $feed->getUrl(), 'label' => _m('URL'), 'block_prefix' => 'row_url']];
$form_definitions[] = [$md5 . '-order', IntegerType::class, ['data' => $feed->getOrdering(), 'label' => _m('Order'), 'block_prefix' => 'row_order']];
$form_definitions[] = [$md5 . '-title', TextType::class, ['data' => $feed->getTitle(), 'label' => _m('Title'), 'block_prefix' => 'row_title']];
$form_definitions[] = [$md5 . '-remove', SubmitType::class, ['label' => _m('Remove'), 'block_prefix' => 'row_remove']];
}
$form_definitions[] = ['url', TextType::class, ['label' => _m('New feed'), 'required' => false]];
@ -242,8 +242,8 @@ class Feeds extends Controller
}
return [
'_template' => 'feeds/edit_feeds.html.twig',
'form' => $form->createView(),
'_template' => 'feeds/edit_feeds.html.twig',
'edit_feeds' => $form->createView(),
];
}

View File

@ -1,7 +1,40 @@
{% extends 'base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ asset('assets/default_theme/css/pages/feeds.css') }}" type="text/css">
{% endblock stylesheets %}
{% block body %}
<div class="section-widget">
{{ form(form) }}
<div class="section-widget section-widget-padded">
<form class="section-form">
<fieldset>
<legend class="section-form-legend">{{ "Edit feed navigation links" | trans }}</legend>
{# Since the form is not separated into individual groups, this happened #}
{{ form_start(edit_feeds) }}
{% for child in edit_feeds.children %}
{% if 'row_url' in child.vars.block_prefixes %}
<div class="section-widget section-widget-padded">
{{ form_label(child) }}
{{ form_widget(child) }}
{% elseif 'row_title' in child.vars.block_prefixes %}
{{ form_label(child) }}
{{ form_widget(child) }}
{% elseif 'row_order' in child.vars.block_prefixes %}
{{ form_label(child) }}
{{ form_widget(child) }}
{% elseif 'row_remove' in child.vars.block_prefixes %}
{{ form_label(child) }}
{{ form_widget(child) }}
</div>
{% endif %}
{% endfor %}
{{ form_end(edit_feeds) }}
</fieldset>
</form>
</div>
{% endblock %}