config.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. Define reusable configuration
  2. =============================
  3. The CKEditor bundle provides an advanced configuration which can be reused on
  4. multiple CKEditor instances. Instead of duplicate the configuration on each form
  5. builder, you can directly configure it once and reuse it all the time. The
  6. bundle allows you to define as many configurations as you want.
  7. .. tip::
  8. Check out the full list of `CKEditor configuration options`_.
  9. Define a configuration
  10. ----------------------
  11. .. code-block:: yaml
  12. # app/config/config.yml
  13. fos_ck_editor:
  14. configs:
  15. my_config:
  16. toolbar: [ ["Source", "-", "Save"], "/", ["Anchor"], "/", ["Maximize"] ]
  17. uiColor: "#000000"
  18. filebrowserUploadRoute: "my_route"
  19. extraPlugins: "wordcount"
  20. # ...
  21. .. tip::
  22. The config node is a variable node meaning you can put any CKEditor
  23. configuration options in it.
  24. .. note::
  25. The first configuration defined will be used as default configuration
  26. if you don't explicitly configure it.
  27. Use a configuration
  28. -------------------
  29. When you have defined a config, you can use it with the ``config_name`` option:
  30. .. code-block:: php
  31. $builder->add('field', 'ckeditor', array(
  32. 'config_name' => 'my_config',
  33. ));
  34. Override a configuration
  35. ------------------------
  36. If you want to override some parts of the defined config, you can still use the
  37. ``config`` option:
  38. .. code-block:: php
  39. $builder->add('field', 'ckeditor', array(
  40. 'config_name' => 'my_config',
  41. 'config' => array('uiColor' => '#ffffff'),
  42. ));
  43. Define default configuration
  44. ----------------------------
  45. If you want to define your configuration globally to use it by default without
  46. having to use the ``config_name`` option, you can use the ``default_config``
  47. node:
  48. .. code-block:: yaml
  49. # app/config/config.yml
  50. fos_ck_editor:
  51. default_config: my_config
  52. configs:
  53. my_config:
  54. # ...
  55. .. _`CKEditor configuration options`: http://docs.ckeditor.com/#!/api/CKEDITOR.config