Skip to content
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

Allow custom rendering of fields and values #738

Open
josdejong opened this issue Jul 13, 2019 · 8 comments
Open

Allow custom rendering of fields and values #738

josdejong opened this issue Jul 13, 2019 · 8 comments

Comments

@josdejong
Copy link
Owner

This topic is (indirectly) discussed here and there already. This is an explicit issue to address this feature.

It would be great to allow custom rendering of both the field (property) and values. That would allow you for example to:

  • Render a JSON schema title instead of the property name in a form (Upgrade to ajv@6 #635 (comment))
  • Render your own dropdown or HTML output, render a map when having a geolocation, render a date picker or stuff like that in certain cases, etc.

The API and usage could look something like:

onRenderValue({ path, field, value, schema, onChange }) => {
  const html = document.createElement('INPUT')
  html.value = value
  html.onchange = function (event) {
    onChange(event.target.value)
  }
  
  return {
    html, 
    update: (value) => {
      html.value = value
    },
    destroy: () => { 
      // clean up any instantiated DOM stuff if needed
    }
  }
}

// onRenderField similar to onRenderValue
@Thaina
Copy link

Thaina commented Aug 6, 2019

Is there anything that don't make this feature possible?

@josdejong
Copy link
Owner Author

@Thaina you could hack into the editor and replace some of the code but I think that will be tricky.

@123survesh
Copy link
Contributor

Hey @josdejong , can I give this feature a try?

@josdejong
Copy link
Owner Author

yes please :), thanks for your offer!

@123survesh
Copy link
Contributor

Hi @josdejong , its been a while I told that I will try this feature out. I have been busy the past few months. Sorry I cannot take it up 😅 .

@josdejong
Copy link
Owner Author

No problem at all, thanks for the update 👍 . I hope all is well with you and your family.

@123survesh
Copy link
Contributor

Thanks for asking, Yes we are doing well here. We have a strict quarantine in place, so we don't go out, except to buy necessary items. Hope its all well and good with you and your family as well.

@josdejong
Copy link
Owner Author

We're bound to home here too, tough no strict quarantine. It's going alright :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants