anomaly/wysiwyg-field_type
A WYSIWYG editor field type for the Anomaly CMS, letting you add rich-text editing to any stream or form with a configurable toolbar and clean HTML output.
This is a PyroCMS Streams Platform field type addon, not a general-purpose Laravel WYSIWYG package. Use it when you are building PyroCMS/Streams-powered admin forms and need a rich-text field.
Install the addon
composer require anomaly/wysiwyg-field_type
php artisan addon:install anomaly/wysiwyg-field_type
In a standard PyroCMS install it may already be present; confirm with php artisan addon:list.
Look first at
src/WysiwygFieldType.php — the field type entry point and input rendering.resources/config/ — editor selection, height, toolbar, and other defaults.First use case
Add a wysiwyg field to a stream, then render it in a Streams form. Programmatically, in a stream migration:
$stream->addField('body', 'wysiwyg', [
'required' => true,
'config' => [
'height' => 400,
],
]);
In the admin CP, create/edit a stream field and choose WYSIWYG as the field type. The field type supplies the form input; your editor addon supplies the toolbar and behavior.
Stream field creation Use the admin UI for quick prototyping, or migrations/seeders for repeatable deployments. The field stores HTML as a string, so it behaves like a textarea with an editor attached.
Form rendering In PyroCMS/Streams forms, let the form builder render the field:
{{ form.fields.body }}
The field type handles the input view, editor assets, and value hydration. Avoid hand-writing <textarea> markup unless you are deliberately bypassing the field type.
Frontend output Values are stored as HTML. Output raw only after sanitizing:
{{ entry.body|raw }}
For user-generated content, run it through an HTML sanitizer (HTMLPurifier or a Twig sanitize extension) before rendering.
Per-field configuration Pass editor options through the field config:
$stream->addField('body', 'wysiwyg', [
'config' => [
'height' => 500,
'toolbar' => 'full',
'allow_tags' => '<p><a><ul><ol><li><strong><em>',
],
]);
Check the field type and editor addon config files for the exact keys supported in your version.
Custom modules Resolve the field type through the Streams field type registry rather than instantiating it directly. This keeps assignment, validation, and rendering consistent with other Streams fields.
Editor swapping If your project uses a specific editor addon, configure it globally in the addon settings and override per field only where needed. This keeps admin UX consistent across streams.
Not standalone Laravel This package depends on the PyroCMS Streams Platform. It will not work as a drop-in WYSIWYG field for a plain Laravel app without PyroCMS addon infrastructure.
Sanitize everything The field type stores whatever the editor submits. Treat all values as untrusted HTML. Sanitize on save or render, especially for frontend-facing content.
Editor assets and caching If the editor does not appear, verify the editor addon is installed and its assets are published. Then clear caches:
php artisan config:clear
php artisan view:clear
php artisan asset:clear
Config precedence Global editor settings usually override defaults, and per-field config overrides global settings. If a field ignores your options, inspect the resolved field config and the editor addon’s config merge behavior.
Changing field types
Converting an existing text or textarea field to wysiwyg is mostly cosmetic because both store strings, but existing values may contain markup the editor cannot safely round-trip. Test migrations against real data.
View overrides To customize the input markup, override the field type’s view in your theme/addon rather than editing vendor files. Keep overrides minimal so future addon updates remain compatible.
Debugging rendering Inspect the generated form HTML first. If the field renders as a plain textarea, the editor JavaScript is likely missing or failing to initialize. Check browser console errors and confirm the editor addon’s service provider is registered.
Extension points
For custom editor behavior, extend the editor addon or provide a custom field type view. Avoid forking wysiwyg-field_type unless you need to change core field-type behavior; most day-to-day customization belongs in config or view overrides.
How can I help you explore Laravel packages today?