-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create custom entity with wysiwyg text field? #83
Comments
Hi, @jmleroux |
Same problem for me in 1.7 version. I can create a TextArea fields using the 'widget' modificator. But I can not use the wysiwyg editor. Thanks and regards |
Editor actually already at codebase and all you need to make it work is to add <?php
namespace AppBundle\Form\Type;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
class WysiwygType extends TextareaType
{
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'textarea';
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'wysiwyg';
}
} # app/config/config.yml
twig:
form:
resources:
- 'AppBundle:Form:pim-fields.html.twig' # src/AppBundle/Resources/services.yml
services:
form.type.wysiwyg:
class: AppBundle\Form\Type\WysiwygType
tags:
- { name: form.type, alias: wysiwyg } {# src/AppBundle/Resources/views/Form/pim-fields.html.twig #}
{% extends 'PimUIBundle:Form:pim-fields.html.twig' %}
{%- block wysiwyg_widget -%}
{% set attr = attr|merge({'class': attr.class is defined ? attr.class ~ ' wysiwyg' : 'wysiwyg'}) %}
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{%- endblock wysiwyg_widget -%} UsageTranslatable custom WYSIWYG field for Category: <?php
namespace AppBundle\Form\Type;
use AppBundle\Entity\Brand;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
use Pim\Bundle\EnrichBundle\Form\Type\CategoryType as BaseCategoryType;
/**
* Type for category properties
*/
class CategoryType extends BaseCategoryType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add(
'longDescriptionTop',
'pim_translatable_field',
[
'field' => 'longDescriptionTop',
'translation_class' => $this->translationDataClass,
'entity_class' => $this->dataClass,
'property_path' => 'translations',
'widget' => 'wysiwyg',
'required' => false,
]
);
}
} |
Thank you very much @igormukhingmailcom , I love when people share their knowledge with each other. That's the way open source should work! |
I added this explaination in the newly created WIKI: https://github.com/akeneo-labs/CustomEntityBundle/wiki/Frequently-Asked-Questions If you think it should be part of the main doc, PR are welcome ;) |
Thank you very much Igor and Jean Marie. Very good job guys. I will try asap. |
Hello
I'm trying to create entity with WYSIWYG field. In Akeneo 1.5 I used pim_wysiwyg field type during form creation, but in Akeneo 1.7 it don't work.
$builder ->add( 'fieldName', 'pim_wysiwyg', array( 'label'=> 'Field Label', 'required'=> false ) );
Does anyone knows how to create form with WYSIWYG field for custom entity?
The text was updated successfully, but these errors were encountered: