Giter Club home page Giter Club logo

translationformbundle's Introduction

A2lix Translation Form Bundle

Translate your doctrine objects easily with some helps

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Branch Tools
3.x (master) Build Status Coverage Status

Documentation

Check out the documentation on the official website.

Support

Contribution help

docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer install --ignore-platform-reqs
docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer run-script phpunit
docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer run-script cs-fixer

License

This package is available under the MIT license.

translationformbundle's People

Contributors

andreybolonin avatar cedriclombardot avatar craue avatar garak avatar grizzlylab avatar holicz avatar inshop avatar jordisala1991 avatar karrakoliko avatar koemeet avatar lemoinem avatar mablae avatar markitosgv avatar mickaelandrieu avatar mmoreram avatar montabou avatar mweimerskirch avatar phenix789 avatar raziel057 avatar rodrigobb avatar rvanlaak avatar scheb avatar sophie-mulard avatar soullivaneuh avatar tchapi avatar tobias-93 avatar tristanbes avatar videl avatar webda2l avatar welcomattic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

translationformbundle's Issues

Render form fields for each translatable field separately

Hey,
this is not a bug report, it's a more like a support request.

I have a LocationTranslation entity with the properties "name" and "city". And I have a Location entity with other properties like zip, street, etc.
In my from I would like to achieve the following order for the fields:

Name Translations
Street
Zip Code
City Translations
Can I build a form like that with the TranslationFormBundle?
Thanks in advance for any help or hint. ;)

Nils

Usage without default locale

Hi,

I'm using the Translatable extension and this bundle for the first time, although I've been using for some time. What I'm trying to achieve is a mechanism similar to the one in the Demo, but without the default locale functionality.

Basically a user would create a version of a Product and choose its language. Afterwards, he would be able to translate it to other languages. The idea is that no single language is required: User A could create Product 1 in English. User B could create Product 2 in French. Product 1 wouldn't exist in French, and Product 2 wouldn't exist in English.

From what I've seen from your bundle, I would have to choose a default language, say English, and force my French users to do both English and French versions.

Is it possible to achieve this using this bundle? If not, do you know any other approach to this?

Thanks for your time
Cheers

Question: Personalization of a2lix_translationsLocale_widget

I want create my form design but widget always generate extra code. With next code (default personalization example) widget generate extra "div" tags with "locale" code (language code).

{% block a2lix_translationsLocale_widget %}
    {% for input in form %}
        {{ form_label(input) }}
        {{ form_widget(input) }}
    {% endfor %}
{% endblock %}

I hide extra code with CSS but would be better use better solution.
PS. I'm new in github and I didn't find how put "question" label for this issue ¬¬

Dynamically inject locales

I would like the option to dynamically inject the list of locales instead of setting it in my config.yml. In my case, locales are Doctrine entities. I would like to be able to query the database and inject the result somehow into your bundle.

At the moment I only have the option to set a static list in config.yml or inject them manually every time I use your form elements. I would like to hook into a service, or be able to add a listener somewhere so I can set the locales to use for all translatable forms.

0.* documentation

It could be a stupid question, but where is the 0.* documentation ?

Thanks.

Slug field also needs translation.

Great bundle - saved me a lof of time.

Anyway, I was wondering if there's any way to slugify the translation (one of the fields).

First problem is that slug field is always visible. Tried using display option but with no results. I accomplished that using 'type' => 'hidden' option.

But still, my slug is not generated. When persisting translation entities as it is in gedmo's tutorials, the english translation slug field is generated from english translation name field.

But when using this bundle the slug field is not even in database.

Do you have solution to this problem, or it is a common restriction.

Thanks!

object_id field empty in my category_translations table

Hi, I'm new to Symfony so I hope this issue is not so stupid ^^
I want to translate my Category entity and I followed the tutorial.
I have a problem when recording the entity after have submitted the form.

In the category_translations table, all traductions appears to be well recorded, exept the object_id column, which is set to "NULL".
(apart from for the default locale, when I set persist_default_translation to true).

So I can't retrieve category's traductions because in the database there is no foreign key bounded...

I can't find the solution.. Could you help me ?
Best regards

No UPDATE OR CREATE after form submission, no errors...

Hi, I'm pretty new to Symfony and I've just tested this bundle, and it looks great. I've managed to modify my Entity, Form, etc, and everything is fine, but when I actually try to create a new and submit the form, the webpage just seems to refresh itself, and I've nothing new in the database. No error is displayed. I've checked my controller and the one in the demo, and I can't see chat is missing... Can somebody help me ?

My contoller action :

public function editproductAction(Product $product)
    {
        $translatableListener = $this->get('stof_doctrine_extensions.listener.translatable');
        $translatableListener->setTranslatableLocale($translatableListener->getDefaultLocale());
        $form = $this->createForm(new ProductType, $product);
        $request = $this->get('request');
        if( $request->getMethod() == 'POST' )
        {
            $form->bind($request);
            if( $form->isValid() )
            {
                $em = $this->getDoctrine()->getEntityManager();
                $em->persist($product);
                $em->flush();
                $this->get('session')->getFlashBag()->add('notice', 'Product successfully edited!');
                return $this->redirect($this->generateUrl('des_sat_products'));
            }
        }
        return $this->render('DESSatBundle:Sat:editproduct.html.twig', array(
            'form' => $form->createView(),
            'product' => $product,
        ));
}

Undefined index at translatableConfig['fields']

What is wrong with this code, https://gist.github.com/RupsNL/5436090

It got this:

Notice: Undefined index: fields in /Applications/MAMP/htdocs/xxxxxx/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/TranslationForm.php line 69

And my table doesn't have the the "descr" and "intro" when I'm following the description steps. That's true? The tablename_translations has id, object_id, locale, field and content.

a2lix_libJS undefined

The standard javascript is not added to the webfolder in symfony2 when you're doing app/console assets:install web

Uncaught ReferenceError: a2lix_libJS is not defined 

handling different default locales in same DB

I am working on an application that is used in multiple websites. Each website potentially has a different default locale. All websites share the same DB and admin (sonata).

I am using sf 2.1 at the moment, so 0.x version of this bundle. I have set

stof_doctrine_extensions:
    persist_default_translation: true

to have the default locale content stored in the translation tables, so I can more easily handle the different default locales.

I am running into issues already but it might just be a matter of kickstarting this.

Do you think this set up is realistic? (with version 0.x or 1.x ..... )

mark only some locales as required

Let's say there's just one field name being translatable in an entity. There are some locales defined, but I want only a few of them to be required. Is that possible currently? I could only mark all locales for that field as either required or not with

$builder->add('translations', 'a2lix_translations', array(
    'default_locale' => 'de',
    'locales' => array('de', 'en', 'ru', 'fr'),
    'fields' => array(
        'name' => array(
            'required' => true,
            'validation_constraint' => new NotBlank(),
        ),
    ),
));

Inheritance in Entity Classes

Hello, I'm using this bundle and it doesn't work as it should when I have 2 classes in my model, one inherits from the other.

Guess this.

Class Product
{
//...something here
}

Class ProductA extends Product
{
//...something here
}

Both classes have translatables fields.
Class Product has its own Translation table => ProductTranslation, just like class ProductA => ProductATranslation

The problem is: Both entities are saving data in each corresponding table in the database but it is not saving anything in the translations tables

What I'm doing wrong ?, thanks in advance
P.S. Sorry about my English

Undefined index: useObjectClass

Hey,

I got an error :

Notice: Undefined index: useObjectClass in /project_path/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/Type/TranslationsType.php line 42

I don't know where useObjectClass come from, but a possible reason could be I use YAML mapping file instead of default annotations for AbstractPersonalTranslation...

I'm stuck. I've no idea what to do. Any clue ?

Stack Trace

in /project_path/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/Type/TranslationsType.php at line 42    
at ErrorHandler ->handle ('8', 'Undefined index: useObjectClass', '/project_path/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/Type/TranslationsType.php', '42', array('builder' => object(FormBuilder), 'options' => array('block_name' => null, 'data_class' => null, 'empty_data' => object(Closure), 'trim' => true, 'required' => true, 'read_only' => false, 'disabled' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'error_bubbling' => true, 'attr' => array(), 'label_attr' => array(), 'virtual' => false, 'compound' => true, 'translation_domain' => null, 'error_mapping' => array(), 'validation_groups' => null, 'validation_constraint' => null, 'constraints' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'extra_fields_message' => 'This form should not contain extra fields.', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_provider' => object(SessionCsrfProvider), 'intention' => 'unknown', 'sonata_admin' => null, 'locales' => array('fr', 'en', 'de'), 'fields' => array(), 'sonata_field_description' => object(FieldDescription), 'by_reference' => false, 'label' => 'form.label_translations'), 'translatableConfig' => array())) 
in /project_path/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/Type/TranslationsType.php at line 42    
at TranslationsType ->buildForm (object(FormBuilder), array('block_name' => null, 'data_class' => null, 'empty_data' => object(Closure), 'trim' => true, 'required' => true, 'read_only' => false, 'disabled' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'error_bubbling' => true, 'attr' => array(), 'label_attr' => array(), 'virtual' => false, 'compound' => true, 'translation_domain' => null, 'error_mapping' => array(), 'validation_groups' => null, 'validation_constraint' => null, 'constraints' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'extra_fields_message' => 'This form should not contain extra fields.', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_provider' => object(SessionCsrfProvider), 'intention' => 'unknown', 'sonata_admin' => null, 'locales' => array('fr', 'en', 'de'), 'fields' => array(), 'sonata_field_description' => object(FieldDescription), 'by_reference' => false, 'label' => 'form.label_translations')) 
in /project_path/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php at line 165    
at ResolvedFormType ->buildForm (object(FormBuilder), array('block_name' => null, 'data_class' => null, 'empty_data' => object(Closure), 'trim' => true, 'required' => true, 'read_only' => false, 'disabled' => false, 'max_length' => null, 'pattern' => null, 'property_path' => null, 'mapped' => true, 'error_bubbling' => true, 'attr' => array(), 'label_attr' => array(), 'virtual' => false, 'compound' => true, 'translation_domain' => null, 'error_mapping' => array(), 'validation_groups' => null, 'validation_constraint' => null, 'constraints' => array(), 'cascade_validation' => false, 'invalid_message' => 'This value is not valid.', 'invalid_message_parameters' => array(), 'extra_fields_message' => 'This form should not contain extra fields.', 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', 'csrf_protection' => true, 'csrf_field_name' => '_token', 'csrf_provider' => object(SessionCsrfProvider), 'intention' => 'unknown', 'sonata_admin' => null, 'locales' => array('fr', 'en', 'de'), 'fields' => array(), 'sonata_field_description' => object(FieldDescription), 'by_reference' => false, 'label' => 'form.label_translations')) 
in /project_path/vendor/symfony/symfony/src/Symfony/Component/Form/ResolvedFormType.php at line 124    
at ResolvedFormType ->createBuilder (object(FormFactory), 'translations', array('sonata_field_description' => object(FieldDescription), 'by_reference' => false, 'label' => 'form.label_translations'), object(FormBuilder)) 
in /project_path/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 87    
at FormFactory ->createNamedBuilder ('translations', 'a2lix_translations', null, array('sonata_field_description' => object(FieldDescription), 'by_reference' => false, 'label' => 'form.label_translations'), object(FormBuilder)) 
in /project_path/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 128    
at FormBuilder ->create ('translations', 'a2lix_translations', array('sonata_field_description' => object(FieldDescription), 'by_reference' => false, 'label' => 'form.label_translations')) 
in /project_path/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 274    
at FormBuilder ->resolveChildren () 
in /project_path/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 210    
at FormBuilder ->getForm () 
in /project_path/vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Admin/Admin.php at line 788    
at Admin ->buildForm () 
in /project_path/vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Admin/Admin.php at line 1235    
at Admin ->getForm () 
in /project_path/vendor/sonata-project/admin-bundle/Sonata/AdminBundle/Controller/CRUDController.php at line 262    
at CRUDController ->editAction ('1') 
at call_user_func_array (array(object(CRUDController), 'editAction'), array('1')) 
in kernel.root_dir/bootstrap.php.cache at line 1426    
at HttpKernel ->handleRaw (object(Request), '1') 
in kernel.root_dir/bootstrap.php.cache at line 1390    
at HttpKernel ->handle (object(Request), '1', true) 
in kernel.root_dir/bootstrap.php.cache at line 1566    
at HttpKernel ->handle (object(Request), '1', true) 
in kernel.root_dir/bootstrap.php.cache at line 617    
at Kernel ->handle (object(Request)) 
in /project_path/web/app_dev.php at line 25

name as field name

I don't know why, but it seems like that if you have fields with the name "name".. there are no form fields shown.. maybe i did something wrong, but maybe somebody can proof that? (i changed the field name to "title" and then again back to "name"... title works, name not...

thank you for your work..

MongoDB Support

It would be really helpful if this bundle would support MongoDB.

The "a2lix_translation_form.translation" service would just need to be configurable for it to work with MongoDB.

no persist if text is empty

i am not sure if i am right or not.. but i think at the moment all translations were persisted in the database even if there are no translations.. so i do have Translations in the DB which do have a content "null". So the "HINT_INNER_JOIN" feature is getting useless.
Am i doing something wrong? or am I right? ;)

Use different entity manager

I'm triyng to connect this bundle with a different entity manager that is not the default one. I'm using doctrine as orm. I would like to know how to achieve this, because the default entity manager is always used.

I tried to change formbuilder options like 'object_manager' or 'entity_manager' but this not work. I have tried to change config options of doctrine extensions and a2lix form bundle without success.

Skipping translatable field in main table.

Is there a way to do the following; I only wanna use the _translations table for all values. So if the main table has a field "description", I only wanna have that in the _translations table, not the main table. Because the main language can change in the future, and I don't wanna fill the default value in the main table.
Is that possible, if so; how? Or can I set/update the default value of the maintable field with the first language of the translation fields?

Error on translating arrays

Hi,

First of all, I'm not sure if this is a bug on your part, so I apologize in advance if it isn't. I'm just hoping you can help me out:

I created a custom form field type called "choice plus other" that, just like the name suggests, has a choice field, with a bunch of options including an "other" which, if selected, displays a text input. This is mapped to an entity field type array. I had to struggle a bit to get it working (for some reason, symfony didn't initialize an array for the field, but a string, which then made doctrine really sad), but now it's done. Next stop, translating it in SonataAdmin.

Here's the real problem: I added the "translatable" annotation to the field, and started getting errors when saving my entity with SonataAdmin, about an array to string conversion. Turns out that the array that comes from the translations section for this field is not being serialized prior to being commited, ence the error. I solved it for now by creating another field type and adding a transformer that serializes it, but I think it would be nice if this could be done automatically.

Like I said, I'm not sure this is a problem with this bundle, so if it isn't, please just point me in the right direction and I'll go knock on somebody else's door.

Thanks for sharing this bundle with the community, it's really useful

cheers

Translatable fields: not persist when updating entity

Hi, I just configure this awesome bundle for sf 2.3 with knplabs translatable behavior and it works perfect!. Entity is saved with translations, But when I try to update entity data, translatables fields are not persisted/updated like the others fields. There are some known issue?

XML config

Hi,

As far as I know the bundle reads the properties annotations in order to add to the form all the fields with the right type (string / text). It does not work for me - I use xml to define database schema not annotations.

See for example: https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/translatable.md#xml-mapping-example

When I add to the admin
$formMapper->add('translations', 'a2lix_translations')

I can see the following error:
Notice: Trying to get property of non-object in [my path]\vendor\a2lix\translation-form-bundle\A2lix\TranslationFormBundle\Form\Type\TranslationsType.php line 139.

Can I set up the bundle to use xml instead of annotations?

Best, Seb

Disabling an item for a locale only

Hi there,

Is there a possibility to disable the display of one item of an Entity depending on the locale ?

An example :

I have a list of products (in a "Product" Entity), which needs to be translated in various languages. But for one (or more) product, I just want no display at all on the product page of a particular locale (let's say in French for exemple). I tried to make my "publication" field translatable, but it doesn't work, as my request in the controler is fetching the "Product" table, and not the "product_translations"...

Is there a way to do that ?

Fatal error: Using $this when not in object context in a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/Type/GedmoTranslationsType.php on line 87

Code:

            'inherit_data' => function(Options $options) {
                $translatableListener = $this->translationForm->getGedmoTranslatableListener();
                return (!$translatableListener->getPersistDefaultLocaleTranslation()
                    && (in_array($translatableListener->getDefaultLocale(), $options['locales'])));
            },

Here should be used "use" not "this":

    $translatableListener = $this->translationForm->getGedmoTranslatableListener();
            'inherit_data' => function(Options $options)  use ($translatableListener) {

                return (!$translatableListener->getPersistDefaultLocaleTranslation()
                    && (in_array($translatableListener->getDefaultLocale(), $options['locales'])));
            },

Templating | Multiple form in a page

Hey !

In default.html.twig , for each navigation element the target is in href attribute :

<a href=".a2lix_translationsFields-{{ locale }}" ...>{{ locale }}</a>

So it's ok for a single form but there is a problem when there are several form. In fact, there are several matched elements - which have "a2lix_translationsFields-{{ locale }}" class.

We should add an unique class name for each class.

Thanks !

Translation entity constructor parameters

Hi,
I'm using translatable entities with personal translation classes. As stated in doctrine extensions documentation, the constructor of my translation class takes 3 arguments: $locale, $field, $value. However, when I try to submit a form using your bundle I get the following error:
Missing argument 1 for ...Translation::__construct(), called in .../vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/EventListener/TranslationFormSubscriber.php on line 100

That's because you initialize the translation class with a constructor taking no parameter. I think either the 3 parameters constructor as mentioned in the doctrine extensions documentation should be tried also, or else it should be stated in the documentation that the constructor of the translation classes should not have any parameter.

Default TranslationEntity Class

This is not working with translation class Gedmo\Translatable\Entity\Translation

<?php

namespace XXX\MainBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;

/**
 * Position Entity class
 *
 * @ORM\Entity(repositoryClass="XXX\MainBundle\Repository\PositionRepository")
 * @ORM\Table(name="position")
 * @UniqueEntity(fields="title", message="position.aready.exists.in.database")
 */
class Position implements Translatable
{
    /**
     * Position id
     *
     * @var integer
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    private $id;

    /**
     * Position name
     *
     * @var string
     * @Gedmo\Translatable
     * @ORM\Column(name="title", type="string", unique = true, length=64)
     */
    private $title;

    /**
     * Used locale to override Translation listener`s locale
     * @Gedmo\Locale
     */
    private $locale;

    /**
     * Sets translatable locale
     * @param    string   $locale
     */
    public function setTranslatableLocale($locale)
    {
        $this->locale = $locale;
    }

    /**
     * Gets id
     *
     * @return int
     */
    public function getId ()
    {
        return $this->id;
    }

    /**
     * Sets title
     *
     * @param   string $title
     * @return  Position
     */
    public function setTitle ($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Gets title
     *
     * @return string
     */
    public function getTitle ()
    {
        return $this->title;
    }
}

Call to undefined method getTranslationClass

since your last change, I've got this error

FatalErrorException: Error: Call to undefined method Entity::getTranslationClass() in /.../vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/EventListener/DefaultTranslationsListener.php line 43

I see that this function is defined in your bundle : https://github.com/a2lix/I18nDoctrineBundle/blob/master/Doctrine/ORM/Util/Translatable.php but I use knplabs and it's getTranslationEntityClass instead of getTranslationClass

changed behavior of marking fields as required

f69d8ef changed the way fields are marked as required.

Previously:

$builder->add('translations', 'a2lix_translations', array(
    'locales' => array('en'),
    'required' => true, // has to be set to be able to mark fields as required
    'fields' => array(
        'name' => array(
            'locale_options' => array(
                'en' => array(
                    'required' => true,
                    'validation_constraint' => new NotBlank(),
                ),
            ),
        ),
        'notes',
    ),
));

This made the fields name required and notes optional.

To get the same result after that change, this has to be used:

$builder->add('translations', 'a2lix_translations', array(
    'locales' => array('en'),
    'required' => true, // has to be set to be able to mark fields as required
    'fields' => array(
        'name' => array(
            'locale_options' => array(
                'en' => array(
                    'required' => true,
                    'validation_constraint' => new NotBlank(),
                ),
            ),
        ),
        'notes' => array(
            'locale_options' => array(
                'en' => array(
                    'required' => false,
                ),
            ),
        ),
    ),
));

Otherwise, the notes field will also be marked as required.

Was that change intentional or would you consider it a bug/BC break?

Update documentation

In the documentation for the Gedmo strategy it's written:

You have to use 'a2lix_translations_gedmo' instead of 'a2lix_translations'

But forgot to say that you should load the gedmo.xml in order to use the type a2lix_translations_gedmo. So in config.yml should look like this:

imports:
- { resource: @A2lixTranslationFormBundle/Resources/config/gedmo.xml }

Different size of textarea for fields

I have three translatable textarea filed (title, description and keywords). Is it possible to define textarea size (width and height) for each fileld individuali inside the a2lix_translations?

For example I would like to have:
title: width 300px and height 40px
description: width 500px and height 70px
keywords: width 500px and height 50px

Is any solution without CSS file and different class for each field?

how can I customize each field label ?

Hi,

my goal is to add some asterisk to the required label so i write in my form type:

public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);

    $builder->add('translations', 'a2lix_translations',
            array_merge(array(
            'fields' => array(
                'firstname' => array(
                    'required' => true,
                    'constraints' => array(new NotBlank())
                ))), array('locales' => array($this->locale)))

but
I try to ovveride the field translation label block without success

{% block translationsLocale_label %}
{% spaceless %}

{% set defualt_token = 'form.' ~ form.name %}
{% set label = label is defined and label ?label:defualt_token %}

    {{  label|replace({'_':'.'})|trans }}{% if required %}*{% endif %}
</label>

{% endspaceless %}
{% endblock %}

any help ?
thanks

Notice: Undefined index: translationClass A2lix/TranslationFormBundle/TranslationForm/GedmoTranslationForm.php

In Sonata admin panel I got an error:

Notice: Undefined index: translationClass in /var/www/.../vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/GedmoTranslationForm.php line 57

my Admin class:

 $formMapper
    ->add('translations', 'a2lix_translations_gedmo', array(
        'translatable_class' => 'Ticket\Bundle\FrontendBundle\Entity\Event',
        'fields' => array(
            'title' => array(
                'type' => 'text'
            ),
            'description' => array(
                'type' => 'textarea'
            )
        )
    ))
;

Notice: Undefined index: fields in ../vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/TranslationForm.php line 69

I am facing problem with symfony2 project using doctrin2 as ORM.
A2lix TranslationFormBundle form giving this warning once i try to edit with an doctrine2 "Proxy" object. It is working fine with doctrine native/origin class object. Can it be solved or suggest me the solution, so we do not need to take care weather it is doctrine native object or proxy object.

As a2lix TranslationFormBundle is important bundle in out project, so can you help me on this issue as soon as possible?

Versions i am using:

"symfony/symfony": "2.2.,
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.
",
"a2lix/translation-form-bundle": "dev-master",

Thanks,

Multiple Required

Is possible to add way to pass separate required=true|false validation parameter to forms having multiple translatable fields and not default_required global config.
thanks

Sonata Admin bundle render "field" and "content" fields instead of translatable fields.

We are trying to implement translationformbundle in our application, all things seems to work but inside sonata admin bundle, when we try to render the fields of translatable fields, it seems that not work.

a2lix

We have marked all the fields translatable in the priamry entity with
@gedmo\Translatable

In Our Admin class we've put:

->add('translations', 'a2lix_translations', array(
'by_reference' => false,
'locales' => array('en','es'),
'fields' => array(
'titulo' => array(
'label' => "titulo",
'type' => 'text',
),
'subtitulo' => array(
'label' => "subtitulo",
'type' => 'text',
),
'text' => array(
'label' => "text",
'type' => 'textarea',
),
)
))

And this fields not appeears in sonata admin. I've attached an image to see what is rendering.
If we try to create manually the translations inside another controller (not sonata admin) we can add the translations normally.

Error with fields option

Hello @a2lix

I'm testing this bundle with Admin Sonata Bundle, but when I put field options I have a error.

This is my mapper:

$formMapper
->add('title')
->add('description')
->add('translations', 'translations',array(
'by_reference' => false,
'locales' => array('fr', 'en'),
'fields' => array( // [Optionnal] Fields configurations. If not, auto detection from translatable annotations
'title' => array(
'label' => 'name', // Custom label
'type' => 'textarea' // Custom type : text or textarea. If not, auto detection from doctrine annotations
),
'description' => array(
'display' => false
)

        )));

And Symfony give this error:

CRITICAL - Symfony\Component\OptionsResolver\Exception\InvalidOptionsException: The option "fields" does not exist. Known options are: "attr", "block_name", "by_reference", "cascade_validation", "compound", "constraints", "csrf_field_name", "csrf_protection", "csrf_provider", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "intention", "invalid_message", "invalid_message_parameters", "label", "label_attr", "locales", "mapped", "max_length", "pattern", "post_max_size_message", "property_path", "read_only", "required", "sonata_admin", "sonata_field_description", "translation_domain", "trim", "validation_constraint", "validation_groups", "virtual" (uncaught exception) at /home/marc/workspace/LoPati2/vendor/symfony/symfony/src/Symfony/Component/OptionsResolver/OptionsResolver.php line 255

What Can I do ?

Thanks

Regards

edit translations when current locale is not the default locale

I'm using two locales currently, German and English, while German is defined as the default one.

If the current locale is German, the translation form is rendered (with tabs for German and English) and handled correctly.

If the current locale is English, the form is rendered as usual, but the tab for the German translation contains the English translation. When submitting the form, the German translation won't be changed at all, but the English translation will be set to the value of the German tab.

Can you reproduce this behavior or must there be something wrong with my form types?

Bug when using default_locale different than symfony default locale

i set in my config.yml:

#a2lix/translation-form-bundle
a2lix_translation_form:
    default_locale: tfng                  # [Optionnal] Default to 'en'
    locales: [fr, ar]               # [Optionnal] Array of translations locales. Can be specified in the form. 
    default_required: false             # [Optionnal] Default to false. In this case, translation fields are not mark as required with html5

and my default symfony locale is fr

i wanted to translate label property of entity Dictionnary, and the logic is to have label in main entity written in tifinagh.

When i use your bundle, i got a problem of duplicate foreign key (fr). but when i changed the defaut locale to fr, it works nice.

ix/translation-form-bundle
a2lix_translation_form:
    default_locale: fr                  # [Optionnal] Default to 'en'
    locales: [en, ar]               # [Optionnal] Array of translations locales. Can be specified in the form. 
    default_required: false             # [Optionnal] Default to false. In this case, translation fields are not mark as required with html5

thanks to fix yhis bug: Dont save the default_locale in Translation entity, when it's a property in the main Enitity.

Bootstrap Javascript.

Hello,

First of all thanks very much for this very usefull bundle.

I followed the instructions included in the following link (http://a2lix.fr/bundles/translation-form/) for the symfony 2.3 + version.

Everything went fine until the moment i started to use the forms. In fact at start everything is broken and the javascript provided didn't really solve the problem.

I'm not very confortable with JS and it took me some time to figure out that the bundle need Bootstrap.js (http://twitter.github.io/bootstrap/getting-started.html) in addition to Jquery.

This can maybe look strange for confirmed javascript users, but i think it would be probably helpfull for people like me if there could be references to those requirements in the documentation.

Now everything is working fine and once again, great work, thanks much for this usefull bundle.

Composer Install / update fails (Failed to clone http://github.com/a2lix/TranslationFormBundle via git, https and http protocols, aborting.)

I have up to date composer (3b2accf) and git (version 1.7.11.msysgit.1) but it constantly fails when updating. Other bundles like "stof/doctrine-extensions-bundle" or "gregwar/image-bundle" are working just fine.

Log of the failing update process:

composer update --prefer-dist -v

Loading composer repositories with package information
Updating dependencies

Exception trace:
() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Downloader/GitDownloader.php:341
Composer\Downloader\GitDownloader->throwException() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Downloader/GitDownloader.php:291
Composer\Downloader\GitDownloader->runCommand() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Downloader/GitDownloader.php:67
Composer\Downloader\GitDownloader->doUpdate() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Downloader/VcsDownloader.php:91
Composer\Downloader\VcsDownloader->update() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Downloader/DownloadManager.php:212
Composer\Downloader\DownloadManager->update() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/LibraryInstaller.php:158
Composer\Installer\LibraryInstaller->updateCode() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/LibraryInstaller.php:105
Composer\Installer\LibraryInstaller->update() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/InstallationManager.php:171
Composer\Installer\InstallationManager->update() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer/InstallationManager.php:138
Composer\Installer\InstallationManager->execute() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer.php:460
Composer\Installer->doInstall() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Installer.php:187
Composer\Installer->run() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Command/UpdateCommand.php:82
Composer\Command\UpdateCommand->execute() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:240
Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Console/Application.php:109
Composer\Console\Application->doRun() at phar://C:/ProgramData/Composer/bin/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:106
Symfony\Component\Console\Application->run() at phar://C:/ProgramData/Composer/bin/composer.phar/src/Composer/Console/Application.php:82
Composer\Console\Application->run() at phar://C:/ProgramData/Composer/bin/composer.phar/bin/composer:39
require() at C:\ProgramData\Composer\bin\composer.phar:15

add forms translation with event listner

Hi,
I got this error
Fatal error: Call to a member function getDataClass () on a non-object in / vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/Form/Type/TranslationsType.php

when i try to use

the ->add ('translations', 'a2lix_translations', array ('local' => $submitedLocales));
in event listner context

my language forms are not fixed, I create a piece of js code to dynamically add forms translation

this is my listner

use Symfony \ Component \ Form \ Event \ DataEvent;
use Symfony \ Component \ Form \ FormFactoryInterface;
use Symfony \ Component \ EventDispatcher \ EventSubscriberInterface;
use Symfony \ Component \ Form \ FormEvents;

TranslationSubscriber class implements EventSubscriberInterface
{
private $ factory;

 public static function getSubscribedEvents ()
 {
     return array (
         FormEvents :: PRE_BIND => 'Prebind'
     );
 }

 public function __ construct ($ FormFactoryInterface factory)
 {
     $ this-> factory = $ factory;
 }

 public function Prebind (DataEvent $ event)
 {
     //jsut for test, locale must be retrieved from ata
     $ local = array ('fr', 'it');
     $ data = $ event-> getData ();
     $ form = $ event-> getForm ();
     / / first call event for parents is null, because of setData (null) in Form constructor.
     if (null === $ form-> getParent ()) {
         return;
     }

     $ form-> add ($ this-> factory-> createNamed ('translations', 'a2lix_translations', null, array ('local' => $ local,

'data_class' => 'PATH \ TO \ MyDataClass')));

}

Can someone give me a clue?

NULL values in base table

Hello. I have a database table:
conf
conf_translation

When i create or edit of the form everything is ok - form data are passed to conf_translation table, but conf table fields (translatable) are null - is there any option to prevent this null values in base table ?

Class 'A2lix\TranslationFormBundle\A2lixTranslationFormBundle' not found in C:\wamp\www\...\app\AppKernel.php

Hi, I successfully downloaded and installed the bundle. I made all configurations according to the readme, but afterwards when I try to access my application, it return the following error:

FatalErrorException: Error: Class 'A2lix\TranslationFormBundle\A2lixTranslationFormBundle' not found in C:\wamp\www...\app\AppKernel.php

Here is the AppKernel

$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new tuto\AccueilBundle\tutoAccueilBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
);
Some help to fix it please ?

Templating

templating is not a config setting but it's referenced like this in the configuration example?
Anyway I can override the default template?

Translatable file upload

Hi,

In the screenshot of your documentation, you show a translatable file upload, do you have any exemple of how to make it?

Thanks,
Nicolas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.