-
Notifications
You must be signed in to change notification settings - Fork 31
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
For relationship fields, it is possible to automatically add the selected value without pressing the "Add" button or change it from Autocomplete to a DropdownList input type? #960
Comments
Hey @DataLoreB4, 👋 thank you for reaching out. Currently, Amplify studio only supports relationships fields on a autocomplete field. |
What about adding the value programmatically in the OnValidate event? Why when I set the value there, then when data is saved, the value is not there? I have other use cases when I hide an input with overrride and then i want to set the value programmatically. ex. overrides={{ I want to set the status in the OnValidate Event, in fact, I can, in fact, if I did not hide the status input and I set a value, I can see it at runtime, but then the value is not saved to the DynamoDB. I there any way to set a value programmatically for an input control and get the value saved using the standard "submit" button of the form? Thanks!! |
Hi @DataLoreB4, if I understand your question correctly you can do this in your local app by updating the For example, if wanting to programmatically set the value of a 'Name' field that you have hidden: return (
<Grid
as="form"
rowGap="15px"
columnGap="15px"
padding="20px"
onSubmit={async (event) => {
event.preventDefault();
let modelFields = {
name: 'NameValue', // update the value of name
dealership,
};
... Then the following validations and DataStore operations in Hope this helps! |
Hi @rtpascual , I'll try that and get back to you, thanks! |
Hi @rtpascual, Sorry, I get it now, you was refering to .jsx generated by amplify all the time, I missundertood. I was able to do what you suggested and it worked exactly as you said: return ( But it's overridden when I pull too. Is there any other option using overrides? Thanks a lot, kind regards, |
Hi @DataLoreB4, Oh I understand, I believe the solution would be to override |
Well, I tried that but I couldn't make It with override because I cannot access the modelFields the same way as I can access them directly in the .jsx file. For example, I can access the values of the fields but not their names:
Can you put me in the right direction to access the fields names and values? Thanks! |
I looked into it a bit more, the fields = {
name: nameValue,
dealership: dealershipValue,
} And in your app, you can programmatically set the value for const handleOnSubmit = (fields) => {
// perform any logic you want for the value of name
return {
...fields,
name: 'NameValue', // this is the same as before of setting name in modelFields in the jsx
}
}
<DealershipCreateForm onSubmit={handleOnSubmit} /> Let me know if this helps. |
Sorry, but I don't get how I can access the field by it's name in place of the value. I need to get or loop fields to identify the right one, and then get It's value. For some reason I only get the values of the fields in the fields object. I'll keep trying, thanks! |
|
Which Specific Feature is your question related to?
Form builder
Question
Hi,
The relationship fields are created by default as "Autocomplete" fields but the thing is that users always forgot to click the "Add" button
Users do not clicks the "Add" button!
(And after the form validation failure, the Add button is disabled, value must be removed and selected again)
Issue reported here
I tried by adding the value right after it's selected, but it didn't work (In fact I was not able to save a value filled on any available event prior to submit like OnValidate, the value is shown in the UI input control but is not there later on DataStore)
Other thing I tried was to turn the field from Autocomplete to DropDownList in Amplify Studio, the type field is a dropdown but the only available option seems to be "Autocomplete".
At least I need to move the Add and Cancel buttons from the right to the left side of the autocomplete textbox, I think I'll have more chances for the users to click "Add" button in that possition.
Hope you can help me, thanks!
The text was updated successfully, but these errors were encountered: