Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwriting block inside grid block with custom theme #987

Open
piotrekkr opened this issue Nov 22, 2017 · 0 comments
Open

Overwriting block inside grid block with custom theme #987

piotrekkr opened this issue Nov 22, 2017 · 0 comments

Comments

@piotrekkr
Copy link

Hi,

I'm trying to extend grid block and add new block inside:

CommonBundle/Resources/views/_partial/grid.html.twig

{% extends 'APYDataGridBundle::blocks_js.jquery.html.twig' %}

{% block grid %}
    <div class="box-header with-border">
        {{ grid_pager_results_perpage(grid) }}

        {{ grid_top_links(grid) }}
    </div>
    <div class="box-body">
        <form id="{{ grid.hash }}" action="{{ grid.routeUrl }}" method="post">
            <table class="table table-bordered table-striped table-hover">
                <thead>
                    {% if grid.isTitleSectionVisible %}
                        {{ grid_titles(grid) }}
                    {% endif %}
                    {% if grid.isFilterSectionVisible %}
                        {{ grid_filters(grid) }}
                    {% endif %}
                </thead>
                {% if grid.massActions|length > 0 %}
                    {{ grid_actions(grid) }}
                {% endif %}
                <tbody>
                    {{ grid_rows(grid) }}
                </tbody>
            </table>
            {% if withjs %}
                {{ grid_scripts(grid) }}
            {% endif %}
        </form>
    </div>
    <div class="box-footer clearfix">

    </div>
{% endblock grid %}

{% block grid_top_links %}
    
{% endblock %}

BackendBundle/Resources/views/dictionary/index.html.twig

{% extends "CommonBundle:layout/backend:main.html.twig" %}

{% set menu_selected = 'settings' %}

{% block content %}
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                Słowniki
                <small>&nbsp;</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="{{ path("backend") }}">Admin</a></li>
                <li><a href="{{ path("backend.settings") }}">Ustawienia</a></li>
                <li class="active">Słowniki</li>
            </ol>
        </section>

        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box">
                        {{ grid(grid, _self) }}
                    </div>
                </div>
            </div>
        </section>
    </div>
{% endblock content %}

{% block grid_top_links %}
    <div class="pull-right">
        <a href="{{ path('backend.dictionary.add') }}" class="btn btn-default btn-sm"><i class="fa fa-plus"></i> Dodaj</a>
    </div>
{% endblock grid_top_links %}

config.yml

apy_data_grid:
    theme: 'CommonBundle:_partial:grid.html.twig'

There is no rendered link in html. grid_top_links is empty. When I try to to use

{{ grid(grid, _self) }}

I get:

An exception has been thrown during the rendering of a template ("Block "grid" doesn't exist in grid template "BackendBundle:dictionary:index.html.twig".").

I also tried using embed in index.html.twig:

{% extends "CommonBundle:layout/backend:main.html.twig" %}

{% set menu_selected = 'settings' %}

{% block content %}

    {% embed "CommonBundle:_partial:grid.html.twig" %}
        {% block grid_top_links %}
            <div class="pull-right">
                <a href="{{ path('backend.dictionary.add') }}" class="btn btn-default btn-sm"><i class="fa fa-plus"></i> Dodaj</a>
            </div>
        {% endblock grid_top_links %}
    {% endembed %}

    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                Słowniki
                <small>&nbsp;</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="{{ path("backend") }}">Admin</a></li>
                <li><a href="{{ path("backend.settings") }}">Ustawienia</a></li>
                <li class="active">Słowniki</li>
            </ol>
        </section>

        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box">
                        {{ grid(grid) }}
                    </div>
                </div>
            </div>
        </section>
    </div>
{% endblock content %}

but I get:

Impossible to invoke a method ("getActionsToRender") on a null variable.

How can I overwrite bloc grid_top_links inside current action view?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant