[Question] change the editForm fields for htmlelement based custom component.
See original GitHub issueI build a custom component, based on the html element. It’s adding a predefined HTML Element (H1).
So far everything works, now I want to use a normal text field for the content, instead of the ace code editor. And I want to hide the field to define the HTML Tag.
This is my custom Element code:
var HtmlComponent = Formio.Components.components.htmlelement;
function HeaderComponent(component, options, data) {
HtmlComponent.prototype.constructor.call(this, component, options, data);
}
// Perform typical ES5 inheritance
HeaderComponent.prototype = Object.create(HtmlComponent.prototype);
HeaderComponent.prototype.constructor = HeaderComponent;
// see: https://github.com/formio/formio.js/blob/master/src/components/html/HTML.js
HeaderComponent.schema = function() {
return HtmlComponent.schema({
type: 'header',
tag: 'h1'
});
};
HeaderComponent.builderInfo = {
title: 'Header',
group: 'basic',
icon: 'fa fa-header',
weight: 70,
documentation: 'http://help.form.io/userguide/#table',
schema: HeaderComponent.schema()
};
HeaderComponent.prototype.render = function(element) {
return this.renderTemplate('html', {
component: this.component,
tag: this.component.tag,
attrs: this.component.attrs || {},
content: this.content,
singleTags: this.singleTags,
});
};
// Use the htmlelement component edit form to build the form element
HeaderComponent.editForm = Formio.Components.components.htmlelement.editForm;
// Register the component to the Formio.Components registry.
Formio.Components.addComponent('header', HeaderComponent);
I suspect it has to do with this, but I can’t tell, where to put this schema.
Thanks for any hint.
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Using custom elements - Web Components | MDN
Customized built-in elements inherit from basic HTML elements. To create one of these, you have to specify which element they extend (as implied ......
Read more >How To Style Common Form Elements with CSS - DigitalOcean
You will create and style this form and its elements by resetting the styles with ... Begin by opening the index.html file in...
Read more >HTML5 form required attribute. Set custom validation message?
Currently when I hit enter when they're both blank, a popup box appears saying "Please fill out this field". How would I change...
Read more >How to Hide Form Fields Based Upon User Selection - Solodev
The Javascript uses jQuery to change the DOM depending on the selections made. Essentially, depending on the conditions of a field answer, you...
Read more >Extending Google Forms with Add-ons | Apps Script
Google Forms is a cloud-based questionnaire and survey solution with ... can use this service to add, modify, rearrange, or remove these form...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
New docs helped 😃 https://help.form.io/developers/custom-components#header-component
@thiagomeireless unfortunately not.
ignore
is the on accepted key. Maybe some day there will be a solution. Or I guess, if we really want to add/change fields in the formbuilder, we have to extend and build from the source…