-
Notifications
You must be signed in to change notification settings - Fork 358
Forms
Martin Maroši edited this page May 13, 2019
·
20 revisions
Information about forms in ManageIQ.
Networks
> Networks
> Configuration
> Add a new Cloud Network
type | physical_network | segmentation_id |
---|---|---|
flat | required | |
gre | required (GRE ID) | |
vlan | required | required (VLAN ID) |
vxlan |
This component uses codemirror editor. You can use it with or without data driven forms.
import CodeEditor, { DataDrivenFormCodeEditor } from '/app/javascript/components/code-editor' // path depends where you use it
name | type | default | required | description |
---|---|---|---|---|
value | string |
undefined |
true |
value of editor |
onBeforeChange | func: (editor, data, value) => void |
undefined |
true |
function that handles value changes |
mode | on of ["yaml", "json"] |
yaml |
false |
Language mode for code editor. Changes code highlight and validation later |
modes | Array of strings |
undefined |
false |
If specified adds radio buttons which will allow you to change between modes. If a prop mode is specified it will be picked as initial language mode |
hasError | bool |
false |
false |
If true changes styling of the editor to represent error state. |
options | Object |
Object |
false |
Use at your own risk. Configuration object for code mirror component. Options can be found here. |
import React, { useState } from 'react'
import CodeEditor from '/app/javascript/components/code-editor'
const MyComponent = () => {
const [value, setValue] = useState('') // set initial code editor value
const handleChange(editor, data, value) => {
//do something with editor or data if you need
setValue(value)
}
return (
<CodeEditor
value={value} // value displayed in editir
onBeforeChange={handleChange} // onChange handler the.
hasError={bool} // sets error
mode="json" // initial language
modes={['json', 'yaml']} // shows radio buttons which allow switching between languages
/>
)
}
const schema = {
fields: [
...
{
component: 'code-editor',
name: 'content',
label: __('Content'),
modes: ['yaml', 'json'],
...any other data driven specific attributes
}
]
}