Giter VIP home page Giter VIP logo

Comments (4)

rainman400 avatar rainman400 commented on July 29, 2024 1

Awesome thanks!

from formengine.

sergeythrees avatar sergeythrees commented on July 29, 2024

Hi, @rainman400

I was wondering if there is functionality for triggering getForm in the FormBuilder component. For example, I want to update the component with form data based on external (to the component) searches. I want to ideally use my ui and api for this. But, once I have the data, I want to feed it to the component and have it render properly. The data is something that I get from the builderRef so it should ideally just plug and play, but I do not see a way to trigger this right now.

We didn't quite understand what you want. Can you please explain in more detail or show me with an example of the code how it should look?

Also, I was wondering if there is a way to hide the toolbar items

We will add this feature in the next release. Thereafter уou can hide specific parts of the interface using CSS selectors. As example:

.FormBuilder .Property > .CodeButton {
   display: none;
}

from formengine.

rainman400 avatar rainman400 commented on July 29, 2024

Let me see if i can pseudo-code something out really quickly:

const [schema,setSchema] = useState<string>('') const getFromApi = (async () => { const apiSchema = await OnlineController.getSchema() setSchema(apiSchema); }) const getSchemaForBuilder = (() => { return schema || '' }) <FormBuilder getForm={getSchemaForBuilder} ...other props />

In this scenario, I want the formBuilder getForm to get triggered everytime 'getFromApi' is called, since it updates the schema variable. I am unsure of how to trigger that though.

For the moment, I have a workaround where I set a 'key' for the FormBuilder and remount it everytime I want to update the schema variable. It's not the worst solution, but maybe there is a better way?

from formengine.

sergeythrees avatar sergeythrees commented on July 29, 2024

@rainman400
There are several ways you can do this. In the code that you have shown, it is enough to add a useCallback:

  const [schema,setSchema] = useState<string>('')
  const getSchemaForBuilder = useCallback((formName?: string) => schema, [schema])
  const getFromApi = (async () => {  
    const apiSchema = await OnlineController.getSchema() 
    setSchema(apiSchema)
  }) 
  return <FormBuilder getForm={getSchemaForBuilder}  ...other props />  

You can also update the schema directly through builderRef:

builderRef.current.parseForm(schema)

or through viewerRef.

viewerRef.current.loadForm(getSchemaForBuilder, name)

This is not a documented API yet, we will add documentation soon.
image
image

from formengine.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.