Skip to content

Commit

Permalink
IBX-6918: Fix form attribute instructions (#2240)
Browse files Browse the repository at this point in the history
* Fix form attribute instructions

Co-authored-by: dabrt <[email protected]>
Co-authored-by: Michał Grabowski <[email protected]>
  • Loading branch information
3 people committed Dec 15, 2023
1 parent f14b50c commit c9b26c6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
return;
}

const CKEditor = richtext.init(richtextContainer);
richtext.init(richtextContainer);
}
);
});

const openUdw = (config) => {
const openUdwEvent = new CustomEvent('ibexa-open-udw', { detail: config });

doc.body.dispatchEvent(openUdwEvent);
};

ibexa.addConfig('richText.alloyEditor.callbacks.selectContent', openUdw);
})(window, window.document, window.ibexa);
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public function buildView(FormView $view, FormInterface $form, array $options):
{
// pass the Dom object of the richtext doc to the template
$dom = new \DOMDocument();
$dom->loadXML($options['richtext_description']);
if (!empty($options['richtext_description'])) {
$dom->loadXML($options['richtext_description']);
}
$view->vars['richtextDescription'] = $dom;
}
}
10 changes: 9 additions & 1 deletion docs/content_management/forms/create_form_attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The new Form attribute requires a `FieldAttributeTypeMapper`. Register the mappe

## Add Symfony form type

The attribute needs to be editable for the form creator, so it needs to have a Symfony form type.
The attribute must be editable for the form creator, so it needs to have a Symfony form type.
Add an `AttributeRichtextDescriptionType.php` file with the form type in the `src/FormBuilder/Form/Type/FieldAttribute` directory:

``` php
Expand All @@ -53,6 +53,14 @@ The templates for the forms should look as follows:
[[= include_file('code_samples/forms/custom_form_attribute/templates/themes/standard/formtheme/formbuilder_checkbox_with_richtext_description.html.twig') =]]
```

Then, specify the new template in configuration, under the `twig.form_themes` configuration key:

``` yaml
twig:
form_themes:
- '@ibexadesign/formtheme/formbuilder_checkbox_with_richtext_description.html.twig'
```
## Add scripts
Now you need to enable the RichText editor. Provide the required script in a new `public/js/formbuilder-richtext-checkbox.js` file:
Expand Down

0 comments on commit c9b26c6

Please sign in to comment.