Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Pass form Object to MuiForms and it should load values in the form. #53

Closed
ahmedsakri opened this issue Feb 5, 2024 · 16 comments
Closed
Assignees
Labels
documentation Improvements or additions to documentation feature new functionality

Comments

@ahmedsakri
Copy link

ahmedsakri commented Feb 5, 2024

Is your feature request related to a problem? Please describe.
I want to pass some values coming from API to the MuiForm tag. I am not able to do so currently. In current scenario. I have to pass it in the value key inside meta object.

Note: this is different from default Values.

Describe the solution you'd like

Something like below will be great.

<MuiForms
    schema={formSchema}
    onSubmit={(formData) => {
        console.log(formData, "Form Submitted Data");
    }}
    onChange={(formData) => {
        // console.log(formData, "Form Data");
    }}
    form={
        type: 'sampleActivity'
        properties: {
            name: "default_name",
            retry_config: {
                retry: 0,
                delay: 0,
                backoff: 1,

            }
        }
    }
/>

Describe alternatives you've considered
I tried searching for alternatives but could not find one.

Additional context
Add any other context or screenshots about the feature request here.

@ahmedsakri ahmedsakri changed the title Pass form Object to MuiForms and it should load default values in the form. Pass form Object to MuiForms and it should load values in the form. Feb 5, 2024
@ahmedsakri
Copy link
Author

@manojadams any thoughts on above?

@manojadams
Copy link
Owner

@ahmedsakri Thank you for your suggestion.

Can you check the following questions:

  • Would like to know any problem you are facing with the current approach for passing input data?
  • Does the schema seems complex to understand?

@ahmedsakri
Copy link
Author

@manojadams Thanks for the quick reply, below are my observations:

  1. Would like to know any problem you are facing with the current approach for passing input data?
    Answer: So, what i am currently doing is i am saving the form Object that i recieve directly in the API. So, in the future, if user wants to open that particular entry of the form what i have is the schema and the form object. With current approach, i will need to write a parser on the fly for the same which will inject the values in the value key inside the meta object.

  2. Does the schema seems complex to understand?
    Answer: The schema is quite easy to understand, it's just of the above scenario. I wanted it to be handled. The other library does this functionalities too:

If you have any alternate approach, I am open to hear and implement this. Thanks a ton!

@ahmedsakri
Copy link
Author

Also, @manojadams If you can look into this ticket. It will be very much helpful for me, as i need it badly at this moment.

@manojadams
Copy link
Owner

Ok. Instead of passing a form object, we can pass a similar object (key, value pair) that we are getting on submit event.
Will this solve your problem?

@ahmedsakri
Copy link
Author

Ok. Instead of passing a form object, we can pass a similar object (key, value pair) that we are getting on submit event. Will this solve your problem?

Yes, this is exactly what i need!

@manojadams manojadams self-assigned this Feb 5, 2024
@manojadams manojadams added documentation Improvements or additions to documentation feature new functionality labels Feb 5, 2024
@ahmedsakri
Copy link
Author

@manojadams I would like to follow-up with respect to this.

@manojadams
Copy link
Owner

@ahmedsakri It is WIP. You can expect a fix by eod.

@manojadams manojadams transferred this issue from manojadams/mui-forms Feb 12, 2024
@ahmedsakri
Copy link
Author

@manojadams Any luck of releasing this?

@manojadams
Copy link
Owner

@ahmedsakri It will take some more time unfortunately.
By when do you need this?

@ahmedsakri
Copy link
Author

@manojadams actually it would be nice if it is targeted by tomorrow. Currently #54 is what i can look forward to and complete the development.

@manojadams
Copy link
Owner

I have pushed the changes to following branch but testing is pending.
https://github.com/manojadams/metaforms-core/tree/feature-54

You can expect by eod once I am back from office.

@ahmedsakri
Copy link
Author

I have pushed the changes to following branch but testing is pending. https://github.com/manojadams/metaforms-core/tree/feature-54

You can expect by eod once I am back from office.

Thanks @manojadams Looking forward to it!

@manojadams
Copy link
Owner

manojadams commented Feb 14, 2024

@ahmedsakri This feature has now been added with following version:
@manojadams/metaforms-core@3.0.42

Example usage:

https://codesandbox.io/p/sandbox/mui-forms-load-initial-form-data-mnplzh?file=%2Fpackage.json%3A13%2C5

@manojadams
Copy link
Owner

Sample form data

import MuiForms from "mui-forms";
import React from "react";
import schema from "./schema.json";

function InitialForm() {
  return (
    <MuiForms
      data={{
        basic_details: {
          first_name: "Bulma",
        },
        more_details: {
          personal_details: {
            last_name: "Bulmamoti",
          },
        },
      }}
      schema={schema}
      onSubmit={(formData) => {
        console.log(formData);
      }}
    />
  );
}

export default InitialForm;

@ahmedsakri
Copy link
Author

Sample form data

import MuiForms from "mui-forms";
import React from "react";
import schema from "./schema.json";

function InitialForm() {
  return (
    <MuiForms
      data={{
        basic_details: {
          first_name: "Bulma",
        },
        more_details: {
          personal_details: {
            last_name: "Bulmamoti",
          },
        },
      }}
      schema={schema}
      onSubmit={(formData) => {
        console.log(formData);
      }}
    />
  );
}

export default InitialForm;

Thanks @manojadams!

Repository owner locked and limited conversation to collaborators Mar 18, 2024
@manojadams manojadams converted this issue into discussion #60 Mar 18, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
documentation Improvements or additions to documentation feature new functionality
Projects
None yet
Development

No branches or pull requests

2 participants