Setting an Initial Values in a Redux Form Edit Newsletter
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

[00:00:01] All right now that we are hiding. We just need to throw that out I mean to our forum here. We need to get the body and the title specifically and then we will move on to actually submit the form and save it to our database where it will update values. So to get started I just want to change a few things in are in our form here I'm the right in a different way slightly. First thing I want to do is I didn't notice that I made this type of way here. Basically what I meant to do is say field input. But there's an easier way to do this and that's just using the spread operator on field thought input which we actually already are doing. So I can get rid of this and it will work. So that will give us all of our field properties that we have in redux form and that's pretty simple and really convenient. So now what I want to do is for now I just want to get rid of these labels or we can always put them in we can put them in our render input. So if I could print the season here and then if we did as we continue then we can put the label there and they grab the input print right here and then we don't have to say title because it's going and we're going to have multiple inputs so we can just do is sit tight or we can say field that input title and that will give us the name or field on the dot name rather that will give us the name of our fuel cells. [00:01:35][94.5]
[00:01:36] They feel that the input name which is Titelman Baldino thrown in there. So we want to do the same thing here. Q Feel input name and that will be great. So now you don't want to put that in here now that can be part of a component. Now what we want to do is change this to a textarea inviting spot be textarea where we might have to do that right there. But for now we just do that again. Now we have canceled them we ever submit. Let's go ahead and save this and see if we're changed much and here it's going to me change or it already has. Yes we our perform here now see what we want to do. We want to get the input into our field that we want to get the text into our embeds. So the way you can do this is by using a nice thing in redux form called initial values and I'm sure you have. So let's scroll down here to our x4 are around her and explore and we will share maps of props and we're displaying the first item but we don't want to put it in here. We want to actually put it in here as a national values and that is what we want to do that is because we're three 3.x form it is going to say OK these are the initial volumes. What's happened to our Enoch's for. So it's going to read title and body. And if you remember our box here if we go to the browser the Fanchet if you click on this we are Titelman we ever buy. [00:03:13][96.5]
[00:03:13] So it's going to go through our our our initial values here. And it is going in and out these over to our over to our field here because it's going to say okay initializes has instead of thinking this was basically a fetish item is this same title and some and then it's saying like 40 and somebody. So basically all we're doing is taking our item and we're putting in additional dollars. So it's an object again. Now when it goes through initial it's going to apply it to our form which is pretty nice let's get rid of this logging and let's say that let's see if this works. They can also go back here and they will reload it and something's not working. But let's take a look. OK so we cancel. It might work if we go back again. I'm glad it's working because there's this. I would consider it kind of a hole maybe it's not a bug because of the way it works. But basically redux form works is they have this value in our column. For that we can put in take at the bottom call enable the initializes has been set to true the formal renationalize. Every time the initial buy these prompts changes. So technically since we are defaults to false. So basically the reason we have to do this is because we're entering this component and we're hitting at it in our thing here I'm reading it and then it goes out and if you remember if you remember the first time you do it when we hit it it doesn't have anything because it's going out right as it mounts. [00:05:09][116.3]
[00:05:10] Then it fetches it and then it assigns props to our computer. So basically the reason we have to use enable the initialise is because the initial volume prompt changes every time this changes it's going to re initialize the form. So basically it's going to go through here again and try to make her day over because now we have something in her initialise. So when it changes when we get our requests back when we get the data back from the server and it sets initial values then it's going to tell our form okay initial values changed and enable the initializes true. So let's renationalize the form. So let's skip the day. So pretty simple we just have to pass it on our results form conflict here. We're going to put this on a new mine so it's more renewable and we just want to basically add in another property here. And remember it's enabled recent so enable Schulweis renationalize you to come here and stay make sure it's all right. So many eyes and renationalize hard yes I forgot my name over. OK I just wanted to be able to type that out coughing but a tsunami of US tsunami hit that it's going to take us into their home. The content that we get it's in there and we are content. Now we can have it. So that's how we do that and then we know that when we hit submit it's going to take us here and it's going to say it's a long train and as a. I'm going to put in another here and a title and body and we'll just see if that's working. [00:07:15][125.0]
[00:07:15] And then if it is we will move on to the next guide and get into the actual request and read the text. We need to do to perform Solecki Kensal units at that and once it's saved and says Turn handles submit. Happy Holidays and underbody so that's great. We're getting our data now. We can do something with it and put it on the server. And as for this hour I'm going to get around to this. Once we complete the feature but for now just ignore it it's a little side of it's a little sidetracked from what we're trying to accomplish. So just ignore these errors he encountered children and we renderers you. Okay so let's hop into the next guy to recommit or code status. Get that kid commit. And what did we want to say and we'll see what did we do. We restructured our field component value and we and we enabled the net in return for config and we set up initial down. Okay and catch the next guy where we will hop into that request. [00:07:15][0.0]
[432.3]