These are chat archives for symfony2admingenerator/GeneratorBundle

8th
Apr 2015
Matej Velikonja
@matejvelikonja
Apr 08 2015 07:56
@loostro for using select2, do I have to add some extra javascript? the multi select form is shown, but select2 is not initalized. I've added AdmingeneratorFormExtensionsBundle::javascripts_assetic_less.html.twig to layout, no JS errors are shown.
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:08
@matejvelikonja Do you have the form_css/form_js somewhere in you code? You will need to use those to print some needed CSS/JS code
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:16
form_css block?
Stéphane
@sescandell
Apr 08 2015 08:16
Hi there

To make symfony2admingenerator/form-extensions-bundle forms work, you need to edit your base template, and include static and dynamic stylesheets and javascripts.

For Admingenerator users:

{% extends 'AdmingeneratorGeneratorBundle::base_admin.html.twig' %}

{% block stylesheets %}
    {{ parent() }}

    {% include 'AdmingeneratorFormExtensionsBundle::stylesheets.html.twig' %}
{% endblock %}

{% block javascripts %}
    {{ parent() }}

    {% include 'AdmingeneratorFormExtensionsBundle::javascripts.html.twig' %}
{% endblock %}

For others:

{% block stylesheets %}
    {% include 'AdmingeneratorFormExtensionsBundle::stylesheets.html.twig' %}

    {% if form is defined %}
        {{ form_css(form) }}
    {% endif %}
{% endblock %}

{% block javascripts %}
    {% include 'AdmingeneratorFormExtensionsBundle::javascripts.html.twig' %}

    {% if form is defined %}
        {{ form_js(form) }}
    {% endif %}
{% endblock %}
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:17
@sescandell I've done it like this, does not work
i'm using generator bundle
Stéphane
@sescandell
Apr 08 2015 08:18
Do you see the generated JS in your page?
(looking into the page code)
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:18
all the JS from javascript.html.twig are loaded
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:18
@sescandell Maybe it would be handy to update that doc, as for the last part you can better use {% if form is defined and form is not null %}, as NULL gives an error but still might be defined
Stéphane
@sescandell
Apr 08 2015 08:19
@bobvandevijver didn't know about that case => ok for your suggestion
could you provide a PR or open an issue in order to not forget it?
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:19
Will do :+1:
Stéphane
@sescandell
Apr 08 2015 08:20
@matejvelikonja ok for the javascript.html.twig but you should also have something else because of
 {% if form is defined %}
        {{ form_js(form) }}
    {% endif %}
Lookt at here:
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:21
wheere should I add this?
Stéphane
@sescandell
Apr 08 2015 08:21
in a javascript block at the bottom of your page
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:22
nice, i've added this and now it works
Stéphane
@sescandell
Apr 08 2015 08:22
the same goes for CSS
{% if form is defined %}
        {{ form_css(form) }}
    {% endif %}
in your stylesheets block
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:23
i guess this should be added to documentation, because from the current docs it's understood that you don' need this if you have admin generator bundle
Stéphane
@sescandell
Apr 08 2015 08:23
and as @bobvandevijver proposed, you can add a more precised test through and form is not none
Actually, the documentation clearly say you have to add it even if you come from Admingen... but maybe it's not clear enough
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:25
it's says for other, which is not really clear
will make a PR
ioleo
@ioleo
Apr 08 2015 08:26
@bobvandevijver you're right, it should be {% if form is defined and form is not empty %}
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:26
Not empty might be the better test indeed
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:26
maybe we can add this block to AdmingeneratorFormExtensionsBundle::stylesheets.html.twig
Stéphane
@sescandell
Apr 08 2015 08:27

it's says for other, which is not really clear
will make a PR

ok, thanks

Matej Velikonja
@matejvelikonja
Apr 08 2015 08:27
do you think it can be added to this file?
@sescandell symfony2admingenerator/FormExtensionsBundle#25
Stéphane
@sescandell
Apr 08 2015 08:32
:+1: ok for the PR, thanks
about your proposition to add the CSS to the stylesheet file...
I think it would work
but this supposed that your form is called form
I mean the variable
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:33
I do not agree with symfony2admingenerator/FormExtensionsBundle#25, that would be something already done for admingenerator users right?
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:33
@bobvandevijver i actually agree with you
should be solved differently
with an option to override this
but at the moment this is how it works
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:35
@sescandell It indeed assumes that the form is called form, already had a few problems with that
Ah, I see that the admingenerator no longer by default uses the FormExtensions symfony2admingenerator/GeneratorBundle@3793c81
So then symfony2admingenerator/FormExtensionsBundle#25 would be okay I guess
Stéphane
@sescandell
Apr 08 2015 08:40
@bobvandevijver yes, GeneratorBundle doesn't use by default the FormExtension
so you effectively need to add the code by yourself even if you're using the GeneratorBundle
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:45
how can I enable sorting in list view?
ioleo
@ioleo
Apr 08 2015 08:48
set sortable: true
(on field, in generator.yml)
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:50
like this
    fields:
      title:
        sortable: true
ioleo
@ioleo
Apr 08 2015 08:50
yes
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:52
but this actually only set the initial sort, right?
ioleo
@ioleo
Apr 08 2015 08:53
no, this enables sorting on that field
(a link on column name is rendered -> click the link to toggle sort ASC/DESC)
to add default sorting you have to modify the controller
Matej Velikonja
@matejvelikonja
Apr 08 2015 08:55
than I found a bug, even if I don't have sortable attribute, I can sort them by clicking on the column na,e
Bob van de Vijver
@bobvandevijver
Apr 08 2015 08:57
builders:
  list:
    params:
      sort: [ your_field, ASC ]
It's old behavior I think, but you can try (we've not yet completed the transition)
ioleo
@ioleo
Apr 08 2015 08:59
@matejvelikonja it's not a bug, by default all columns (fields) have sortable enabled see code
@bobvandevijver i didnt remember that one :) wonder if it works
ouch... @loostro have been faster!

@bobvandevijver i didnt remember that one :) wonder if it works

of course it (should be) is: that's how you can define the default order on your list

Matej Velikonja
@matejvelikonja
Apr 08 2015 09:01
i see, thx for the help
ioleo
@ioleo
Apr 08 2015 09:04
@sescandell i've never used it :D
Bob van de Vijver
@bobvandevijver
Apr 08 2015 09:05
Ha, I knew something @loostro didn't :smile:
ioleo
@ioleo
Apr 08 2015 09:07
there is a lot of legacy code written by @cedriclombardot , and I never used some parts of it... ^^
I think only filter button should be submit
because once i type something in filter and press enter i assumed that filtering will occur, and not resetting like it works now
ioleo
@ioleo
Apr 08 2015 09:23
this is intended
Stéphane
@sescandell
Apr 08 2015 09:23
This is fixed in #96
ioleo
@ioleo
Apr 08 2015 09:23
i mean, the button submit
just switched button order
Bob van de Vijver
@bobvandevijver
Apr 08 2015 09:24
They both need to submit the data, so both need to be submit buttons
Matej Velikonja
@matejvelikonja
Apr 08 2015 09:25
ok great. when this will be merged? :)
ioleo
@ioleo
Apr 08 2015 09:26
when it's ready :P
Matej Velikonja
@matejvelikonja
Apr 08 2015 09:26
hehe
Stéphane
@sescandell
Apr 08 2015 09:27
what is remaining?
Tests ?
Bob van de Vijver
@bobvandevijver
Apr 08 2015 09:27
All the checkboxes in the initial PR message are checked, so I hope it won't take long anymore :D
Stéphane
@sescandell
Apr 08 2015 09:27
is there any ODM or Propel user here?
I think the most unsure part are about ODM and Propel into this PR
ioleo
@ioleo
Apr 08 2015 09:28
this problem comes back with every major PR.. we don't have anyone active useing ODM/Propel to test /comment :P
Matej Velikonja
@matejvelikonja
Apr 08 2015 09:28
I use ORM, sorry
@loostro for the long run, are you planning to do some kind of single app administration? using angular or something like that?
Stéphane
@sescandell
Apr 08 2015 09:30
we need to hire :D
Tobias Feijten
@tobias-93
Apr 08 2015 09:30
Maybe you should just merge, see if anyone comes up with broken ODM/Propel :)
ioleo
@ioleo
Apr 08 2015 09:31
thats what we did in the past.. we did our best to read Propel/ODM docs and keep it up to date.. but honestly, I don't know if (and what) works there
but noone is complaining...
so either we have no Propel/ODM users
Bob van de Vijver
@bobvandevijver
Apr 08 2015 09:31
Maybe it is time to drop support
ioleo
@ioleo
Apr 08 2015 09:31
or we're so genious to make no mistakes :D
Stéphane
@sescandell
Apr 08 2015 09:32
I think second option is right :p
Bob van de Vijver
@bobvandevijver
Apr 08 2015 09:32
Yeah, I do not believe that last one :smile:
Genious okay, but no mistakes, impossible! :sparkles:
ioleo
@ioleo
Apr 08 2015 09:58
lately i feel more like a vampire
sometimes a vampire genious (at those rare occasions i get something right at first try)
but mostly vampire slave (becouse i work hard all day and night :P)
Bob van de Vijver
@bobvandevijver
Apr 08 2015 09:59
Shouldn't vampires sleep during the day? ;)
ioleo
@ioleo
Apr 08 2015 10:03
yes they should, but i am cursed and doomed to suffer terrible illness called "deadline"
Bob van de Vijver
@bobvandevijver
Apr 08 2015 10:04
:p
ioleo
@ioleo
Apr 08 2015 10:05
btw has anyone created queries with AVERAGE score?
eg. Post -> hasMany -> Scores
i'm trying
<?php
  $query
      ->select('post', 'p')
      ->leftJoin('p.scores', 's')
      ->addSelect('AVG(s.rating) AS hidden avg_rating')
but when I do ->addOrderBy('avg_rating', 'ASC') i get empty resultset
(before adding the addOrderBy and addSelect the query returned 25 results)
Bob van de Vijver
@bobvandevijver
Apr 08 2015 10:09
Do you only need the average? I've got a single case in which I use SUM, and that is with select instead of addSelect
ioleo
@ioleo
Apr 08 2015 10:09
how do you use sum?
Bob van de Vijver
@bobvandevijver
Apr 08 2015 10:10
$qb = $this->createQueryBuilder('tr');
    $qb->select('SUM(tr.amount)');
Stupid enters :smile:
That is inside a entityrepository btw
ioleo
@ioleo
Apr 08 2015 10:11
yes im working in a repository too now
can i do SUM(x) / COUNT (x) as mycolumn?
Bob van de Vijver
@bobvandevijver
Apr 08 2015 10:11
I get the result by executing return $qb->getQuery()->getSingleScalarResult();
I assume that just replacing SUM with AVG should do the job
Stéphane
@sescandell
Apr 08 2015 10:13
@loostro I think you missed a groupBy. If I well understand what you want to do, you need to add a groupBy(p)
ioleo
@ioleo
Apr 08 2015 10:14
oh yes! @sescandell that did the trick thank you :D
maybe i will finish this and go to sleep today :P there is a small chance :P
Stéphane
@sescandell
Apr 08 2015 10:14
:+1:
@sescandell can I add prefix to this {{ name }}, because if you you have property that has the same name as some class in bootstrap you get bad styling. for example I have a lead property and that class lead is added automatically, which coresponds to some class in bootstrap
or is somethng (like some JS) using this class
ioleo
@ioleo
Apr 08 2015 11:38
this class is simply for your convinience, it's not used in any JS
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:39
but do you see the problem?
ioleo
@ioleo
Apr 08 2015 11:39
yes
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:40
I suggest we change {{ name }} with form-{{ name }} or something
or maybe even better control-group-{{ name }}, since this is the control group div
ioleo
@ioleo
Apr 08 2015 11:41
won't bootstrap add some CSS when we prefix it with control-group ?
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:42
it already has control-group class
ioleo
@ioleo
Apr 08 2015 11:42
ah.. true
:+1: for control-group- prefix
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:44
symfony2admingenerator/FormExtensionsBundle#28
@loostro I’m really happy that you are so willing to help and also that you accept PR that fast. Thx.
ioleo
@ioleo
Apr 08 2015 11:46
np
I hope that you and others stay longer with this bundle and help us improve it
as you can see, there are many "small" things that can be easily fixed
but thats just too much for 1 person
and as I said before - there are some parts of this bundle I don't use (or use rarely)... and they get little attention
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:48
I’m aware of that. I’m trying this bundle for the first time, for some project that we have, it looks very promising. I hope it will stay this way :)
ioleo
@ioleo
Apr 08 2015 11:49
i hope others (with diffrent projects, diffrent needs) may see issues where I don't and report (or maybe submit PRs.. heheh :) )
how do you find this bundle? is it easy / hard? does it have enough features? or maybe it's "too fat"?
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:51
the biggest problem that I see at the moment is the lack of documentation or at least really pimped out demo with all the possiblitiyes, so you can easily see how you can do stuff.
i think you should invest some time to this demo project and add all possibilities to it, like this select2 dropdowns, image upload, gallery upload, ...
ioleo
@ioleo
Apr 08 2015 11:52
yes i plan to do that
i hope this month i will be able to start doing it
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:53
I think this would boost up other developer to use this. Also it would be nice to show to the customer how the administrator for their project would look like
ioleo
@ioleo
Apr 08 2015 11:53
when i get my new job, i should be really financially secure and "don't have to do extra freelance projects", which should give me more time for this
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:54
that’s really good
I just hope that you won’t be overoccupied with the new job, and leave the bundle on the side
ioleo
@ioleo
Apr 08 2015 11:54
well i wont leave the bundle for sure
but true, I don't know how hard will my new job be
Matej Velikonja
@matejvelikonja
Apr 08 2015 11:55
BTW: I’m also developing one bundle https://github.com/matejvelikonja/LabbyBundle and you can give it a try, of course if it fits your needs
ioleo
@ioleo
Apr 08 2015 11:55
i dont even know what project i will be assigned to :) they have not told me yet :P
ill have a look
Matej Velikonja
@matejvelikonja
Apr 08 2015 13:39
ioleo
@ioleo
Apr 08 2015 13:40
copy/paste mistake
Matej Velikonja
@matejvelikonja
Apr 08 2015 13:40
shoud I fix this?
ioleo
@ioleo
Apr 08 2015 13:42
fixed
Matej Velikonja
@matejvelikonja
Apr 08 2015 13:42
krel, thx
kewl
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:11
@loostro I’ve seen this in form extensions documentation
addFormOptions:
widget: fieldset
    # use generated embed type
    type:           \Acme\MediaBundle\Form\Type\Video\EditType
but it says that widget does not exists. is this some lefover from previous version?
ioleo
@ioleo
Apr 08 2015 14:12
which form type are you refering to?
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:16
videos:
label: Videos
dbType: collection
formType: collection
addFormOptions:
widget: fieldset
    # use generated embed type
    type:           \Acme\MediaBundle\Form\Type\Video\EditType
    allow_add:      true
    allow_delete:   true
    by_reference:   false
    options:
      label:          Image
      data_class:     Avocode\MediaBundle\Entity\Video
 videos:
      label:            Videos
      dbType:           collection
      formType:         collection
      addFormOptions:
        widget:         fieldset
        # use generated embed type
        type:           \Acme\MediaBundle\Form\Type\Video\EditType
        allow_add:      true
        allow_delete:   true
        by_reference:   false
        options:
          label:          Image
          data_class:     Avocode\MediaBundle\Entity\Video
it’s from this documentation
ioleo
@ioleo
Apr 08 2015 14:20
OK, the form type has changed
it's s2a_collection_table or s2a_collection_fieldset
there is no longer widget option
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:21
so instead of \Acme\MediaBundle\Form\Type\Video\EditType i use on of this two?
ioleo
@ioleo
Apr 08 2015 14:21
no
these are just form types that extend standard symfony2 collection type
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:22
so what do i do?
ioleo
@ioleo
Apr 08 2015 14:22
what is so special about collection type? it holds a "group" of similar form types
it has an option type telling what form types it hold
so you can have a collection of integer types
or a collection of text types
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:23
so basically i just remove the widget? and tha’s that?
ioleo
@ioleo
Apr 08 2015 14:23
(note these are "simple types")
you can also have a collection of \Your\Class\Compound\Type
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:24
like in the example, yes
ioleo
@ioleo
Apr 08 2015 14:24
you remove the nonexisting option widget
and use formType: s2a_collection_HERE
insted of HERE choose "fieldset" or "table"
they work the same (and have same options) they just look diffrent
videos:
      label:            Videos
      dbType:           collection
      formType:         s2a_collection_table
      addFormOptions:
        # use generated embed type
        type:           \Acme\MediaBundle\Form\Type\Video\EditType
        allow_add:      true
        allow_delete:   true
        by_reference:   false
        options:
          label:          Image
          data_class:     Avocode\MediaBundle\Entity\Video
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:26
it works
will you update the c
docs?
ioleo
@ioleo
Apr 08 2015 14:26
if you could make a PR please, I am on deadline now
in 30 minutes client comes...
Matej Velikonja
@matejvelikonja
Apr 08 2015 14:28
i don’t have time at the moment also