These are chat archives for symfony2admingenerator/GeneratorBundle

11th
May 2015
Serg N. Kalachev
@ksn135
May 11 2015 14:29
Good evening, everyone!
Strange behaviour. When filter list on associated column then filtertype form method isValid() always return false. Workaround commented out isValid() call in ListController and everything now works as expected. WTF ?
Ideas ?
Bob van de Vijver
@bobvandevijver
May 11 2015 14:34
@ksn135 You probably want to post your generator config, but I guess you're missing the filterable: true in the column definition
Serg N. Kalachev
@ksn135
May 11 2015 14:34
Hmmm. Yes, it's true. I've just removed it.
Serg N. Kalachev
@ksn135
May 11 2015 14:39
My config:
generator: admingenerator.generator.doctrine
params:
    model: AppBundle\Entity\Payment
    namespace_prefix: 
    concurrency_lock: ~
    bundle_name: AppBundle
    pk_requirement: ~
    fields: 
        date:
            label:    Дата
            filterable: true
            filterType:  s2a_date_picker
            formType:    s2a_date_picker

        unit:
            label:    Отдел
            filterable: true
            # formType:      s2a_select2_entity 
            # filterType:    s2a_select2_entity            
            # addFormOptions:
            #     configs:
            #         placeholder: Не выбрано

        estimate:
            label:    Статья
            filterable: true
            # formType:      s2a_select2_entity 
            # filterType:    s2a_select2_entity            
            # addFormOptions:
            #     configs:
            #         placeholder: Не выбрано

        contractor:
            label:    Контрагент
            filterable: true
            # formType:      s2a_select2_entity 
            # filterType:    s2a_select2_entity            
            # addFormOptions:
            #     configs:
            #         placeholder: Не выбрано

        notes:
            filterable: true
            label:    Комментарий

        summa:
            label:    Сумма

    object_actions:
        delete: ~
    batch_actions:
        delete: ~
builders:
    list:
        params:
            title:  Список платежей
            display: 
                -    date
                -    contractor
                -    summa
                -    unit
                -    estimate
            actions:
                new: ~
            object_actions:
                show: ~
            filters: 
                -    date
                -    contractor
                -    unit
                -    estimate
                -    notes
    excel:
        params: ~
        filename: ~
        filetype: ~
@bobvandevijver Still not working, cache cleared twice ))
Bob van de Vijver
@bobvandevijver
May 11 2015 14:47
@ksn135 Next time you might want to post only the relevant bit of the generator ;)
However, at the moment I do not have a clue why this config shouldn't be working
You might want to try to find out why the method you posted returns false, there should be some indication on why it returns that ;)
Serg N. Kalachev
@ksn135
May 11 2015 14:48
@bobvandevijver sorry about that (big post).
$form->getErrors() is empty
Stéphane
@sescandell
May 11 2015 14:50

Hi @ksn135 ,

Could you check one field after one to see if this is "global" or only because of one field?

Serg N. Kalachev
@ksn135
May 11 2015 14:51
@sescandell Thanks, I'll try
Serg N. Kalachev
@ksn135
May 11 2015 15:00
@sescandell Very interesting. If I use two associated columns in filters it's working only if both field set to specific values
for example, if I filtering by unit (Departament A) and estimate (Others) it's works.
But if I choose in filter only unit (Departament A) and filed estimate left blank, then filtersType form method isValid() return false and method getErrors() return none.
Is it by design or I've made a mistake somewhere ?
Stéphane
@sescandell
May 11 2015 15:06
could you check your estimation field options and check required is not true ?
Bob van de Vijver
@bobvandevijver
May 11 2015 15:10
@sescandell I think that we should set required to false for every filter by default, as in my opinion no field of a filter should be required
Stéphane
@sescandell
May 11 2015 15:10
@bobvandevijver agree with you
just wondering if it is working or not
:)
Bob van de Vijver
@bobvandevijver
May 11 2015 15:11
Off course :) Is there already a ticket for this?
Serg N. Kalachev
@ksn135
May 11 2015 15:13
@sescandell Well, it's not working
                unit:
                    filterable: true
                    addFormOptions:
                        required:    false
                estimate:
                    filterable: true
                    addFormOptions:
                        required:    false
Stéphane
@sescandell
May 11 2015 15:14
which version of SF are you using?
Serg N. Kalachev
@ksn135
May 11 2015 15:15
+1 for automatically set "required: false" for all fields listed under filters key
Symfony version 2.7.0-BETA1 - app/dev/debug
sf 2.7.0 in the debug toolbar you should have the form debug panel
and you can check individual options
what is esstimate formType?
Bob van de Vijver
@bobvandevijver
May 11 2015 15:18
@sescandell Don't you think that the column.formOptions already contains the resolved default parameters from the model, such that it contains required => true for every required field in you model?
Serg N. Kalachev
@ksn135
May 11 2015 15:20
so, currently to use filters I should change doctrine entity, nullable=true ?
Stéphane
@sescandell
May 11 2015 15:22

@sescandell Don't you think that the column.formOptions already contains the resolved default parameters from the model, such that it contains required => true for every required field in you model?

This is not impossible

so, currently to use filters I should change doctrine entity, nullable=true ?

No, I think it's just:

  • a matter of field option
  • or an issue with the formType used
Could you look at the generated formtype file
and copy paste it?
(please)
Serg N. Kalachev
@ksn135
May 11 2015 15:25
Stéphane
@sescandell
May 11 2015 15:28
so, just to be sure: everything is working, except when you put the estimate field "alone" and you submit the form without any entity selected, am I right?
Serg N. Kalachev
@ksn135
May 11 2015 15:29
It's works, when both field have selected values, if one is empty than it's fails
My current config: http://pastebin.com/bqP7pPks
May be I should add something like addFilterOptions ?
Stéphane
@sescandell
May 11 2015 15:33
addFilterOptions no, this option doesn't exists
if you want to "override form options" for filters, you can do it under the params key in the list builder definition
Serg N. Kalachev
@ksn135
May 11 2015 15:35
Did you see my config ? I think it's correct. Generated filter type form file seems too.
Well, I could downgrade to 2.6 to check it out if you say so
Stéphane
@sescandell
May 11 2015 15:36
formTYpe and filterTYpe under the list param are redundant, but yes it seems to be correct
could you please remove them (both) and let the default behavior, just to check if it is working or not?
Serg N. Kalachev
@ksn135
May 11 2015 15:37
ok
Nope
may be I should duplicate same records under param -> fields key ?
Serg N. Kalachev
@ksn135
May 11 2015 15:46
Well, I've to go, I dig into this later and notify all about results
Thanks a lot for your attention!
Serg N. Kalachev
@ksn135
May 11 2015 17:52

@sescandell I found problem via Symfony profiler in submitted filter form:

Symfony\Component\Form\Exception\TransformationFailedException
Unable to reverse value for property path "[estimate]": The choice "" does not exist or is not unique

But I don't know how to fix it (

Stéphane
@sescandell
May 11 2015 18:00

It might be one of the following:

  • FormExtensionBundle is broken
  • You should add in your generator the empty_value and empty_data field

Maybe this is just a miss-configuration of ChoiceField

Serg N. Kalachev
@ksn135
May 11 2015 18:02
It's not choice field, it associated field in other table
Stéphane
@sescandell
May 11 2015 18:02
Yes, but the form field type is a s2a_select_entity
which is a choice field if i'm not wrong
Serg N. Kalachev
@ksn135
May 11 2015 18:06

Add form options:

                estimate:
                    formType:      s2a_select2_entity 
                    filterType:    s2a_select2_entity
                    filterable: true
                    addFormOptions:
                        required:    false
                        empty_value: ""
                        empty_data: ""

Here is part of my Entity:

    /**
     * @var Estimate
     *
     * @ORM\ManyToOne(targetEntity="Estimate")
     * @ORM\JoinColumn(name="estimate_id", referencedColumnName="id")
     * @Assert\NotNull
     */
    private $estimate;
Is there easy way to downgrade to symfony 2.6 ? Modify composer.json ?
Stéphane
@sescandell
May 11 2015 18:08
do you really think this is due to sf2.7 ?
yes you can: edit your composer.json
put the ~2.6.0 version
and run composer update symfony/symfony
Serg N. Kalachev
@ksn135
May 11 2015 18:09
@sescandell I don't know, just to check
it's pet project, no problem
Stéphane
@sescandell
May 11 2015 18:10
"pet" ?
Serg N. Kalachev
@ksn135
May 11 2015 18:10
small, just of fun
Stéphane
@sescandell
May 11 2015 18:10
k
Serg N. Kalachev
@ksn135
May 11 2015 18:11
BTW, many deprication warnings in 2.7
Stéphane
@sescandell
May 11 2015 18:12
Yes... we should manage all of this... but some of them imply BC Breaks or upgrading the minimum version of SF (so BC Break too)
Serg N. Kalachev
@ksn135
May 11 2015 18:15
DEPRECATED - The "request" service is deprecated and will be removed in 3.0. Add a typehint for Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the request instead.  
DEPRECATED - Calling the Symfony\Component\OptionsResolver\OptionsResolver::setAllowedTypes method with an array of options is deprecated since version 2.6 and will be removed in 3.0. Use the new signature with a single option instead.
DEPRECATED - The FormTypeExtensionInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeExtensionInterface with Symfony 3.0. 
DEPRECATED - The FormTypeInterface::setDefaultOptions() method is deprecated since version 2.7 and will be removed in 3.0. Use configureOptions() instead. This method will be added to the FormTypeInterface with Symfony 3.0.
DEPRECATED - The Symfony\Component\OptionsResolver\OptionsResolver::setNormalizers method is deprecated since version 2.6 and will be removed in 3.0. Use setNormalizer() instead.
Several of them about form options, so I'll check it out under old (2.6) version
Serg N. Kalachev
@ksn135
May 11 2015 18:30
So, 2.7 is NOT supported yet (
Symfony version 2.6.7 - app/dev/debug
YES! Everything works as expected!
@sescandell Thank you very much for your support!
Stéphane
@sescandell
May 11 2015 18:31
hmmm... this is interesting... it means Symfony introduced a BC Break :) It would be interesting to know more about why this bug...
Serg N. Kalachev
@ksn135
May 11 2015 19:09
@sescandell I could try to dive deeply into 2.7 to understand this BC, but I don't know well Symfony form internals...
Bob van de Vijver
@bobvandevijver
May 11 2015 20:03
Well, they did change a lot in de forms (for example those FormOptions resolver), which they deprecated without having a successor ready -.-