Skip to content
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

IBX-6918: Fix form attribute instructions #2240

Merged
merged 6 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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