Custom metadata schema field
- April 6, 2017
- 6 replies
- 7095 views
I have extended the granite UI to create a user picker metadata schema field. It works fine the first time but when i go back to the metadata schema editor and edit it, the custom user picker changes back to text field. Not sure why it is happening. Any ideas?
I have followed these steps to create new metadata schema field.
1. In CRXDe Lite, create the following path under /apps/dam:
/apps/dam/gui/coral/components/admin
2. Navigate to /libs/dam/gui/coral/components/admin, and copy the schemaforms folder into the
path created above
3. In open this folder your local apps directly, and navigate to formbuilder. Open the builditems.jsp.
4. At line 66 of the builditems.jsp, added the code snippet to render a new field.
<li class="field" data-fieldtype="text">
<div class="formbuilder-template-title">
<i class="coral-Icon coral-Icon--sizeM coral-Icon--text"></i>
<span><%= i18n.get("User picker custom") %></span></div>
<script class="field-properties" type="text/x-handlebars-template">
<sling:include resource="<%= fieldTemplateResource %>"resourceType="dam/gui/coral/components/admin/schemaforms/formbuilder/formfields/customfield" /></script></li>
5. Navigate back to /apps/dam/gui/coral/components/admin/schemaforms/formbuilder/formfields.
Create a directory called customfield. From the textfield directory (also in this formfields directory),
copy over the textfield.jsp. Rename this coustomfield.jsp.
6. Replace the resourceType calls to refer to a customfield.
<sling:include resource="<%= resource %>"resourceType="granite/ui/components/coral/foundation/form/customfield"/>
<input type="hidden" name="./items/<%= key %>/sling:resourceType" value="granite/ui/components/coral/foundation/form/customfield">
7. create the following path:
/apps/granite/ui/components/coral/foundation/form/
8. Navigate to the equivalent path under libs. From here, copy the userpicker folder and paste this into the path you created in the
last step, under apps and rename it to customfield.
Thanks!