-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Question] change the editForm fields for htmlelement based custom component. #2110
Comments
HeaderComponent.editForm has the edit form. You'll probably want to modify it to make your changes. Just look through the editForm and find the right component and make the changes to it. |
I tried a few things, but I get lost in all the different json keys. I made a fiddle with my custom Header Component. http://jsfiddle.net/nv9o51q3/2/ I couldn't find a way to modify How to achieve this? And how can I set the weight in my I hope that makes sense. Thank you. |
When setting the editForm directly you need to send the whole form json. If you use the config in the component definition there is an extend functionality like this: https://github.com/formio/formio.js/blob/master/src/components/html/HTML.form.js#L7-L24 |
Thank you for pointing this out. So I suppose I am able to merge my configuration this way: HeaderComponent.editForm([{
key: 'api',
ignore: true,
}
]); but it doesn't do anything (removing the API tab) http://jsfiddle.net/0xfwh3cu/2/ (sorry for asking for support here, but gitter is not really active and hard to search in, and I found most solutions so far here.) |
I believe you need to add the array in "components" (i have not tried this so not sure if it would work, but it should) HeaderComponent.editForm({
components: [{
key: 'api',
ignore: true,
}
]
}); |
@travist thank you. I tried it, but no luck http://jsfiddle.net/0xfwh3cu/4/ :/ From the code that @randallknutson linked to[1] and the compiled source [2] it should be just
that gets merged, but it doesn't do anything (or I'm missing something) I'm trying really hard to find a rule of thumb when and how to use what keys and where (switching between chrome console, source code, docs and trial&error), but it's still overwhelming with all those options. So much potential. [1] https://github.com/formio/formio.js/blob/master/src/components/html/HTML.form.js#L7-L24 |
editForm is a function that returns an edit form. The edit form is NOT an array but an edit form object. The object contains a components array. Your best bet is to replace the function with a function that returns the form object with the components that you want. |
ok, I almost gave up, but I managed to customize the edit form for my custom component. The solution to merge custom definitions was to use, as @randallknutson recommended a function and via trial and error I found the HeaderComponent.editForm = function() {
return HtmlComponent.editForm([
{
key: 'layout',
ignore: true
}
]);
}; A working jsfiddle is here: http://jsfiddle.net/0xfwh3cu/9/ My custom Header component is derived from the The last question I have is: How do I turn the How can I overwrite this field? Thanks so far for the hints... |
I have to come back to this. For my custom component I'm able to overwrite most components in the modal. http://jsfiddle.net/23f1g485/3/ HeaderComponent.editForm = function() {
return HtmlComponent.editForm([
{
label: 'OVERWRITE ME',
weight: 100,
key: 'display',
ignore: false,
components:[
{
key: 'refreshOnChange',
ignore: true
},
{
// originally a textarea with Ace editor.
type: 'textfield',
key: 'content',
input: true,
ignore: false,
//editor: 'ace',
//rows: 10,
//as: 'html',
label: 'xContent'
weight: 80
}
]
}
]);
}; I went through the code with the debugger and tried to make sense out of it, but at some point (presumably here: https://github.com/formio/formio.js/blob/90c7c71b31/src/components/_classes/component/Component.form.js) the default settings overwrite my custom settings and nothing happens. If someone could make that fiddle (http://jsfiddle.net/23f1g485/3/) work, that would be fantastic (or maybe it's a bug in the code) Thanks. |
Hey @marcus-at-localhost, did you find a solution for this problem? I'm also trying to change some of the default I can create new checkboxes with custom keys without problem, setting the desired label/tooltip, but I need to use the |
@thiagomeireless unfortunately not. |
Maybe that will help: |
New docs helped :) https://help.form.io/developers/custom-components#header-component |
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:
I suspect it has to do with this, but I can't tell, where to put this schema.
Thanks for any hint.
The text was updated successfully, but these errors were encountered: