question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] change the editForm fields for htmlelement based custom component.

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
marcus-at-localhostcommented, May 7, 2020

@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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found