Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Radosław Miernik
    @radekmie
    I just saw that getModel is not documented... Well, maybe it's even better...? Anyway, you can use it.
    Adam Tolley
    @refactorized
    getModel is what I was looking for originally, I felt like it should exist, but couldn't find it. Is there any reason I should not use it?
    Radosław Miernik
    @radekmie
    The only against is that it's not documented.
    Adam Tolley
    @refactorized
    @radekmie Above when you say ' but a simple wrapper to ValidatedQuickForm' do you mean a class which extends it, or a component which wraps it. I am using a hooks component and wrapping a ValidatedQuickForm, managing the state inside my component and updating the model prop when changes are made. The problem I am having is that there is a lag between changes to this model prop and the change in the form.
    Console logs illustrate that each keystroke is in fact changing the state, and quickly, but the re-render seems to take place only after a brief delay and the changes are batched. This doesn't happen with a plain AutoForm which (reading the source) extends the ValidatedQuickForm and calls its setState method rather than passing through props. This difference is the only thing I can think of that might be causing input response lag. Does that sound plausible?
    If that's the case I have several workarounds (we discussed above) I can employ, but I would like to understand why I am seeing this behavior
    danyhiol
    @danyhiol
    Uncaught TypeError: tslib_1.__spreadArrays is not a function at SimpleSchema2Bridge.js.SimpleSchema2Bridge.getInitialValue Since the last update, I'm getting this strange error. I've found that it occurs for every array field define in simpleSchema2.
    Charles Eric Vincent
    @cvincent-atmanco
    Hey guys, just started looking over your library, it looks really promising!
    Just 1 quick question... I tried it out with a fairly simple JSON Schema, and I'm having trouble rendering array properties. It seems like it renders a field for it, but is not rendering the Add and Del buttons/icons, therefore I cannot add any data to the list field. Is this expected behaviour? Do I have to customize my form with ListFields under the AutoForm to make this work? I'm using uniforms-bootstrap4, but the problem is the same with uniforms-bootstrap3. My JSON schema looks like this:
    {
      "title": "Guest",
      "type": "object",
      "properties": {
        "competencies": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": { "type": "string" }
            }
          }
        }
      }
    }
    Charles Eric Vincent
    @cvincent-atmanco
    ^ Turns out it's because it requires the octicons icon package to be available in the app. Overriding the .octicon selector fixed it for me. Would be nice to implement other icons such as FontAwesome, or maybe a fallback such as a '+' or a '-' when octicons aren't available.
    Radosław Miernik
    @radekmie
    @refactorized Yes, it's actually true. The thing is that the change has to be fast enough to work properly. That's why AutoForm has both model and modelSync.
    @danyhiol It looks like we are depending on a too low version of tslib. Could you file this in an issue, please?
    Radosław Miernik
    @radekmie
    @cvincent-atmanco This theme was designed some time ago and it just stuck to the Octoicons. You can use the ListAddField (ListDelField) prop addIcon (removeIcon) to change it: https://github.com/vazco/uniforms/blob/d3f7f852c0b8d589b7415206d31448d4c54af990/packages/uniforms-bootstrap4/src/ListAddField.tsx#L24. It's really possible to detect any font icon in the component, so it won't work like that. We should definitely mention it in the docs though.
    danyhiol
    @danyhiol
    @radekmie done.
    Charles Eric Vincent
    @cvincent-atmanco
    @radekmie Thanks for the feedback.
    Also had another question. Does the JSON Schema Bridge supports the latest Draft Version 7? I'm specifically asking about the if, then & else keywords.
    Do you also know if there's issues with nested allOf keywords?
    Radosław Miernik
    @radekmie
    @cvincent-atmanco Partially. Currently we are not extracting much information from such keywords, but if you are using them just for the validation part, then it works.
    danyhiol
    @danyhiol
    I'm getting another weird error: Uncaught TypeError: Class constructor _a cannot be invoked without 'new'. This is after updating to the very last version.
    Radosław Miernik
    @radekmie
    @danyhiol I saw your comment and posted a few questions - will get to it later today
    danyhiol
    @danyhiol
    There is a strange behavior happening with arrays-field. image - image. When defining an array with minCount and options, there are null entries in the array. While simpleSchema requires using minCount to make an array not empty.
    Radosław Miernik
    @radekmie
    Yep, that's weird.
    I think it actually worked in the past...
    As always, file an issue please.
    And thanks again for a report.
    danyhiol
    @danyhiol
    @radekmie okay, that has been done.
    metamn
    @metamn
    hello all :D
    I've tried both uniforms and react-jsonschema-form ... and ... only frustrations :) The idea sounds so well but I can't simply figure out how to use these libraries
    Note: I'm an experienced developer using, reusing, and creating lots of packages ... and still :)
    For example the example in this issue comment simply doesn't works : https://github.com/vazco/uniforms/issues/517#issuecomment-470690363 ... and it's given by the maintainer itself
    metamn
    @metamn
    And how on earth one can provide a solution without checkbox fields? https://uniforms.tools/docs/api-fields
    No offense :) Just curious ... how others managed to get by ....
    Does anybody is using this package generating any kind of forms coming from an API? Or is used just for simple use cases like a signup form?
    Radosław Miernik
    @radekmie
    Hi @metamn.
    It's normal that certain comments may be obsolete or simply broken with time (this comment is over 9 months old).
    If you have any problems like this, just file an issue (or comment). I saw you did that already and that's great.
    I've been using uniforms for a lot of generated forms, even user-defined ones so it works.
    There may be (and certainly are) some problems with the docs - if you think that something should be added/changed/removed there - write it here, file an issue, or even a PR if you have time.
    Mikhail Surin
    @antimony
    Hi, is there an option to update form on schema update? I want to get schema from server on page load and build form after that. But when I'm trying to pass schema promise to JSONSchemaBridge constructor, form remains blank
    Radosław Miernik
    @radekmie
    Hi @antimony. All forms will rerender on schema change. You cannot pass a Promise as a schema or bridge though. Just wait for the promise to resolve in your code and then use it normally.
    Jeremy Peters
    @jeremypeters
    Hi. Quick question - is there any documentation regarding all of the properties and values that can be used when using JSON Schema? For example in https://uniforms.tools/docs/examples-common-forms there are uniforms, const, $data, etc.
    Radosław Miernik
    @radekmie
    Hi @jeremypeters. In general everything without $all/$any works. By works I mean that it'll correctly render a form and validate the input. What may not work is a correct error reporting, as some of these issues may be on a different level (e.g. parent value). If you'll have anything that won't work - do file an issue.
    Yuom Theara
    @thearabbit
    I base on Meteor, Simple Schema.
    How to create custom schema for Uniform (from server)
    // Method
    Meteor.methods({
      existName(name) {
        return name == 'Rabbit'
      },
    })
    --------------
    //  Custom Msg
    SimpleSchema.setDefaultMessages({
      messages: {
        en: {
          CustomMsg: 'This is custom msg!',
        },
      },
    })
    
    // Schema
      name: {
        type: String,
        async custom() {
          const result = await Meteor.call('existValue', this.value)
    
          if (result) {
            return 'CustomMsg'
          }
        },
      },
    But don't work, please help me
    Jeremy Peters
    @jeremypeters
    @radekmie Thanks for the info.
    Jeremy Peters
    @jeremypeters
    Just another quick question: We were hoping to use Uniforms to generate forms completely from JSON provided by our API. However it look like this is not possible, because if we need to use a component (e.g. LongTextField) this is not specified in the schema as a string. Or am I missing something?
    Radosław Miernik
    @radekmie
    @jeremypeters I’ve also worked on a similar solution and what I’ve done was to map the receiver schema. In your case it’d be replace string to component reference.
    Jeremy Peters
    @jeremypeters
    Great, thanks again for the info @radekmie
    Alvin
    @alvin
    I'm using a variety of advanced autoform components with JSON Schema bridges -- but have run up against a strange issue with nested object values. I thought everything was working until I actually tried to enter text in one of many fields I set up... somehow the onChange handler isn't accepting text for these, even though the nested object schema is valid. Is it perhaps something with the bridge? Same result with a NestField wrapper as well:
    <AutoField  label="Step Title"  name="locale.step2Title" placeholder="eg. My Priorities"  />
    Radosław Miernik
    @radekmie
    HI @alvin. This code looks OK, maybe there's an error in the console? Anyway, file an issue on GitHub with more information and we'll take it from there.
    Patrick Machado
    @p1Machado

    Hello guys. I want to separate client-side validations from backend validations. I'm used to do it using React Final Forms with submitError like this example: https://final-form.org/docs/react-final-form/examples/submission-errors
    Is there any similar approach when using uniforms?

    I did it using onSubmitFailure, but found it a bit painfull to have all that maping and a useState:

    const [errors, setErrors] = useState(null);
    return <AutoForm
      schema={FornecedorSchema}
      error={errors}
      onSubmit={onSubmit}
      onSubmitSuccess={() => setErrors(null)}
      onSubmitFailure={(error) => {
        if (error.response?.status === 400 && error.response.data.fieldErrors) {
          setErrors({
            details: error.response.data.fieldErrors.map(({ message, field: missingProperty }) => ({
              dataPath: "." + missingProperty,
              keyword: "required",
              message,
              params: { missingProperty },
            })),
          });
        }
      }}

    Thank you :)

    Radosław Miernik
    @radekmie
    Hey there @p1Machado. You can reject from onSubmit with that error, which simplifies it a little. In the end, you'll always have to build the error object, as we don't know how it may look like - it's schema-dependent.