sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Froala Symfony bundle for Symfony (WYSIWYG editor) not working with Sonata-admin #4773

Closed napso closed 6 years ago

napso commented 6 years ago

Environment

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.22.0 3.25.1 The missing Symfony Admin Generator
sonata-project/block-bundle              3.3.2  3.4.0  Symfony SonataBlockBundle
sonata-project/cache                     1.0.7  1.0.7  Cache library
sonata-project/core-bundle               3.4.0  3.7.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.2.1  2.2.1  Symfony SonataDatagridBundle
sonata-project/doctrine-orm-admin-bundle 3.1.6  3.1.7  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter                  1.7.1  1.7.1  Lightweight Exporter library

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.1.0 v3.1.2  Symfony MonologBundle
symfony/phpunit-bridge     v3.3.6 v3.3.13 Symfony PHPUnit Bridge
symfony/polyfill-intl-icu  v1.5.0 v1.6.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.5.0 v1.6.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php56     v1.5.0 v1.6.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.5.0 v1.6.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.5.0 v1.6.0  Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0 v3.0.0  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.3 v3.0.3  Symfony SwiftmailerBundle
symfony/symfony            v3.3.6 v3.3.13 The Symfony PHP framework

PHP version

$ php -v
PHP 5.6.30 (cli) (built: Jan 22 2017 10:10:16)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Subject

KMSFroalaEditorBundle is a symfony bundle that provides a custom formType to show the froala tich text editor.

normally in Symfony, you can just do the following:

$builder->add( "yourField", "froala" ); // Symfony 2
$builder->add( "yourField", FroalaEditorType::class ); // Symfony 3

however, when trying to add the froala type i get the follownig error:

Impossible to access an attribute ("options") on a null variable in 

Steps to reproduce

Expected results

The froala rich text editor.

Actual results

Impossible to access an attribute ("options") on a null variable in 
jordisala1991 commented 6 years ago

Could you provide an stack trace of the error?

gotzmann commented 6 years ago

Same problem here! I'm trying to use Froala within Admin class:

   protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add("text", FroalaEditorType::class)

But that code fails with the error:

Impossible to access an attribute ("options") on a null variable.

It throwns from that line:

vendor\sonata-project\admin-bundle\src\Resources\views\Form\form_admin_fields.html.twig (line 340):

{% if sonata_admin is defined and sonata_admin.options['form_type'] == 'horizontal' %}
jordisala1991 commented 6 years ago

I will leave this opened for now, but I dont see how is this suposed to be related with Sonata.

Probably the fix will need to be applied on Froala side.

Can someone take a look at my comment there? https://github.com/froala/KMSFroalaEditorBundle/issues/17#issuecomment-377077882

Once we confirm the bug is there, I will close the issue here.

jordisala1991 commented 6 years ago

Closing for now.. if someone wants to fix this and thinks it is on Sonata side, please ping to reopen, with the information we have, it is probably related to Froala form render.

gansky-alexander commented 4 years ago

Hello, guys !

Is possible to create own formatter for Froala ? do you have any documentation how to do this ? I am going to implement my own, i think i can to make PR with it to sonata formatter bundle but i do not know tow to implement it in right way.

wbloszyk commented 4 years ago

Hello, @gansky-alexander !

You can find documentation in https://sonata-project.org/bundles/formatter/3-x/doc/index.html and in doc directory for each bundle. You can check how it is work in current code too.

Remember about "Froala Editor" license do not allow use it in Open Source Product (terms). We probably can merge integration code but with license info (like here) and without any Froala Editor code.