|
|
Line 1: |
Line 1: |
| <!-- !!! -->
| | The content on this page has moved to https://documentation.open-xchange.com/latest/ui/customize/forms.html |
| <!-- PLEASE APPLY CHANGES ONLY TO THE NEW TECHNICAL DOCUMENTATION: wd/frontend/web/documentation -->
| |
| <!-- !!! -->
| |
|
| |
|
| {{Stability-experimental}}
| | Note: Open-Xchange is in the process of migrating all its technical documentation to a new and improved documentation system (documentation.open-xchange.com). Please note as the migration takes place more information will be available on the new system and less on this system. Thank you for your understanding during this period of transition. |
| | |
| <div class="title">Extension points:<br>Modifying forms</div>
| |
| | |
| '''Abstract'''
| |
| | |
| ''This articles covers how to apply different changes to the contact form via modifying its extensionpoints and extensions.''
| |
| | |
| | |
| __TOC__
| |
| ==Show available extension points==
| |
| | |
| The edit form of the contacts app is constructed by a set of extension points. Each extension point controls a single aspect of the form. To apply modifications, the id of the point and the extension is needed. For a quick overview of the available points and extensions you can use the browser console:
| |
| | |
| <pre class="language-javascript">
| |
| // show all available extension points (across all apps)
| |
| require('io.ox/core/extensions').keys();
| |
| </pre>
| |
| | |
| <pre class="language-javascript">
| |
| // you can filter down the list by using regular expression
| |
| _(require('io.ox/core/extensions').keys()).filter(function (point) {
| |
| if (/io.ox\/contacts\/edit/.test(point)) {
| |
| return point;
| |
| }
| |
| });
| |
| </pre>
| |
| | |
| <pre class="language-javascript">
| |
| // show all available extensions of a known extension point
| |
| require('io.ox/core/extensions').point('io.ox/contacts/edit/personal').all();
| |
| </pre>
| |
| | |
| ==Modify extension points==
| |
| | |
| As described in [[ AppSuite:Extending_the_UI_(Hands-on_introduction) | Hands-on_introduction]] extension points can be modified in multiple aspects:
| |
| | |
| <pre class="language-javascript">
| |
| // disable the display_name field
| |
| require('io.ox/core/extensions').point('io.ox/contacts/edit/personal').disable('display_name');
| |
| | |
| // reenable the display_name field
| |
| require('io.ox/core/extensions').point('io.ox/contacts/edit/personal').enable('display_name');
| |
| </pre>
| |
| | |
| <pre class="language-javascript">
| |
| // replace the display_name field by "Hallo World!"
| |
| require('io.ox/core/extensions').point('io.ox/contacts/edit/personal')
| |
| .replace({
| |
| id: "display_name",
| |
| draw: function () {
| |
| this.append(
| |
| $("<div>").addClass("title").text("Hello World!")
| |
| );
| |
| }
| |
| });
| |
| </pre>
| |
| | |
| <pre class="language-javascript">
| |
| // modify the index of the display_name field to bring it on top
| |
| require('io.ox/core/extensions').point('io.ox/contacts/edit/personal')
| |
| .replace({
| |
| id:"display_name",
| |
| index: 50
| |
| });
| |
| </pre>
| |
| | |
| <pre class="language-javascript">
| |
| // modify the hidden status to hide the display_name field via get() as alternative way
| |
| require('io.ox/core/extensions').point('io.ox/contacts/edit/personal')
| |
| .get('display_name', function (extension) {
| |
| extension.hidden = true;
| |
| });
| |
| </pre>
| |
| | |
| ==Extending the form validation via extension points==
| |
| | |
| In addition to the default validation, another validation step can be implemented by extending the proper extension point:
| |
| | |
| <pre class="language-javascript">
| |
| // extend the validation of the display_name field
| |
| require('io.ox/core/extensions')
| |
| .point('io.ox/contacts/model/validation/display_name')
| |
| .extend({ | |
| id: 'check_for_klaus',
| |
| validate: function (value) {
| |
| if (value !== 'Klaus') {
| |
| return 'The display name has to be Klaus';
| |
| }
| |
| }
| |
| });
| |
| </pre>
| |
| | |
| [[Category:AppSuite]]
| |
| [[Category:UI]]
| |
| [[Category:Extension points]]
| |