Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
I want to show you an example of calling a method of a component from within the action attribute of a form. And I have two pages set up here, booking form instance and booking properties. I'm going to take this form, and call a method from within the booking properties component within the action page to display the results of the form. So I'll put it in the browser first.
And I'll scroll down here, and fill this out. Once I fill it out, I'll click Book A Tour, and yes, number of people is not perfect. But that's not going to affect what we're doing. And you can see, (LAUGH) that's why number of people doesn't look quite perfect. But what I did was called a method of the booking properties. The method was, display tour details. What I did was placed that information, that URL, right here within the action attribute of the form.
Now, in this example, you can see, its going to our local host. But what you would do is put the domain name in this action area. And if you had any arguments for that particular method, what we could do is put an ampersand. And this would be argument one, as an example, equals. And whatever argument one would be, I'll just say the number one ampersand. So you would just keep adding those if you needed to when you called the method. I don't need any of that for this particular example. It's just calling the method of display tour details. Now, somewhat needless to say, this is not the most secure way to work with a component.
It also assumes that this is not an instantiated component, so this is simply a static method call from a component. But it is possible to do, I wanted to make you aware that that's possible within the display tour details method. I do have a couple of pieces in here, you can see, access equals remote. And my return type on this particular example is set to a string, because it's going to return all of this information. But this access equals remote attribute of our display tour details method is necessary in order to be able to access it through that particular method, by calling it with the action attribute of a form.
Now, it is possible to have different access types for methods. As you can see, there are three different access types within this component. So, if you make a method access equals remote, you are not limited in that you have to make every method within the component that same access level. Your components can store different methods with different access levels, depending upon your needs. But that is how you can use a method call for a component, from the action attribute of a form.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 103232 Viewers
61 Video lessons · 89966 Viewers
71 Video lessons · 73543 Viewers
56 Video lessons · 105085 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.