четверг, 14 июля 2016 г.

5 columns layout with Twitter Bootstrap

based on http://www.wearesicc.com/quick-tips-5-column-layout-with-twitter-bootstrap/ , modified for fitting 5 columns in any >320px width displays.

.col-xs-15,
.col-sm-15,
.col-md-15,
.col-lg-15 {
  position: relative;
  min-height: 1px;
  padding-right: 10px;
  padding-left: 10px;
}

@media (min-width: 320px) {
  .col-md-15 {
    width: 20%;
    float: left;
  }
}

And use it like this:
<div class="col-md-15 col-sm-3">
    ...
</div>

понедельник, 11 июля 2016 г.

how to fix Symfony CSRF token is invalid. Please try to resubmit the form

If you have problems with uploading files, you should not disable  CSRF, only fix it with this hints:

* make sure in php.ini (in all directories in /etc/php5/) max_post_size much bigger than upload_size.
* do not forget to restart server (apache or nginx) and "service php5-fpm restart"

среда, 6 июля 2016 г.

How to add radiobuttons field in Sonata-Admin

protected function configureFormFields(FormMapper $formMapper) {
$formMapper
->add('lang', 'choice', [    'expanded' => true,    'choices' => [    '0' => 'LV',    '1' => 'RU',    '2' => 'EN'        ]]);
}

how to fix \ValidateRequestListener' not found in \ContainerAwareEventDispatcher.php

Just delete cache folder in /app/cache/prod or dev.

Pool::validate() must be an instance of ..\ErrorElement, instance of ..\ErrorElement given

Just downgrade sonata-project/media-bundle to 2.3.3. In my situation it was 2.3.4.

Thanks to https://github.com/sonata-project/SonataMediaBundle/pull/963

пятница, 1 июля 2016 г.

Sonata-admin how to add entity filter

protected function configureDatagridFilters(DatagridMapper $datagridMapper){    $datagridMapper        ->add('id')        ->add('translations.name', null, ['label' => 'Name'])        ->add('eanCode')        ->add('catalogCode')        ->add(            'product', null, [], 'entity', [            'class'    => 'AppBundle\Entity\Product',            'property' => 'name'        ])    ;}

In the beginning I thought that 'entity' doesn't work in sonata-admin ^2.3, 
and tried 'doctrine_orm_choice'. It could get elements in dropdown, but filter didn't 
worked correctly (results always was empty, but there should be elements).

working Apache2.4 virtualhost with Symfony2.8

dont forget to add to /etc/hosts with 127.0.0.1 project.dev;
Include "C:/wamp64/alias/*"
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "c:/wamp64/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "e:/Coding/php/symfony/project/web"
    ServerName project.dev
    <directory "e:/Coding/php/symfony/project/web">
        Options Indexes FollowSymLinks
        AllowOverride All
Allow from all
Require local
    </directory>
ErrorLog "C:/wamp64/logs/apache_error2.log"
    CustomLog "C:/wamp64/logs/apache_error-custom.log" combined
</VirtualHost>