Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Filter-date-range labels for left_date and right_date widgets #84

Closed
jbator opened this issue Jan 29, 2014 · 6 comments
Closed

Filter-date-range labels for left_date and right_date widgets #84

jbator opened this issue Jan 29, 2014 · 6 comments

Comments

@jbator
Copy link

jbator commented Jan 29, 2014

Is there any way to customize those labels?

I tried to override whole template file "form_div_layout.html" by copying source file and paste it in app/Resources/LexikFormFilterBundle/views/Form/form_div_layout.html and then add my own theme for filter_date_range_widget but this is not working - bundle is still using source file. Clearing the cache did not help :(

Also I tried adding label in filter type like this:

->add('made', 'filter_date_range', array(
                'label' => 'Rok produkcji',
                'left_date_options' => array('label' => 'od'),
                'right_date_options' => array('label' => 'do'),
            ))

but this is not working.

@L0rD59
Copy link

L0rD59 commented Jan 29, 2014

Do you have add your templating in twig configuration in app/config/config.yml ?

twig:
    form:
        resources:
            # Default:
            - form_div_layout.html.twig
            # Example:
            - MyBundle::form.html.twig

@jbator
Copy link
Author

jbator commented Jan 29, 2014

My config looks like this:

twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%
    form:
        resources:
            - 'MyBundle:Form:fields.html.twig'
            - 'LexikFormFilterBundle:Form:form_div_layout.html.twig'

@L0rD59
Copy link

L0rD59 commented Jan 29, 2014

Maybe it's troubleshooting with TwigBundle i haven't try with the same configuration,

Ok the FrameworkBundle search in app/Resources then in inherit bundle, then in the bundle. But maybe TwigBundle don't !?

In my case i have inherit the FormFilterBundle

class LIGFormFilterBundle extends Bundle
{
    public function getParent()
    {
        return 'LexikFormFilterBundle';
    }
}

And i have extends the original template in MyBundle/Resources/views/Form/form_div_layout.html.twig

{% extends 'LexikFormFilterBundle:Form:form_div_layout.html.twig' %}
#override here your block

And i put both template of both Bundle in Twig configuration

# Twig Configuration
twig:
    form:
        resources:
            - LexikFormFilterBundle:Form:form_div_layout.html.twig
            - LIGFormFilterBundle:Form:form_div_layout.html.twig

Can you try something like that ?

@jbator
Copy link
Author

jbator commented Jan 29, 2014

Ok, i found working solution:

I created new twig file

MyBundle/Resources/views/Form/form_div_layout.html.twig

which doesn't extend anything but have only customized block code:

{% block filter_date_range_widget %}
    <div class="filter-date-range">
        <div class="filter-date-range-left">
            {{ form_label(form.left_date) }}
            {{ form_widget(form.left_date, {'attr': attr}) }}
        </div>
        <div class="filter-date-range-right">
            {{ form_label(form.right_date) }}
            {{ form_widget(form.right_date, {'attr': attr}) }}
        </div>
    </div>
{% endblock filter_date_range_widget %}

and included this file in my config:

# Twig Configuration
twig:
    form:
        resources:
            - 'MyBundle:Form:fields.html.twig'
            - 'LexikFormFilterBundle:Form:form_div_layout.html.twig'
            - 'MyBundle:Form:form_div_layout.html.twig'

@L0rD59 thanks for pointing me to correct solution

@L0rD59
Copy link

L0rD59 commented Jan 29, 2014

Can you close this issue please ?

Thx, and good road

@jbator
Copy link
Author

jbator commented Jan 29, 2014

Ok, closing and thanks.

@jbator jbator closed this as completed Jan 29, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants