I have two views from a form, one is loaded in my codeigniter index, and another is loaded in its on function. how do i make the form work so that when i click submit on the first form it loads the new view/function as the new
if i understand your question,
i think you need to set the action of the first form to be the url of your second controller
<form action=/controller/form2 >
or you can do a redirect
or you can simply load the form2 instead of form1
Related
I have only one php file called index.php. I have created there a form with one input text element and one input submit element. When I click on submit I want to deal with the value from the input element in the function that is in the same file, namely index.php. So my question is what to write into action attribute of the form element, if i will write index.php it doesnt work properly because then I get to the dashboard of wordpress. (I am trying to create a wp plugin).
-I am PHP and also Wordpress beginner-
I think the quickest way is just not to set any action on the form html tag. That way it will just POST/GET data to the same page from where you're calling it. Does this make it for you?
I am porting an application to codeigniter developed in core PHP. By default query string functionality is disabled and I don't want to turn it on because I want the URLs to look clean. I have a page where there three forms: login form, registration form and forget password form. By default all the forms are collapsed. When the user opens this page from some other page by clicking on 'Login' button then login form should expand, and if the action of the user was "Register" button then registration from should exapnd when page is loaded. The earlier developer has appended action attribute to button links and added "login" and "register" values to them. This helps him to retrieve whether request was for login or register and he expands the collapsed form accordingly. But since codeignter URLs don't work this way how do I remember the user action when login or register button is clicked?
I am sorry if I could not write it clearly what I am trying to ask, if further information is needed I can edit and write more.
Thanks!
When in controller save the action in a variable:
$data = array();
$data['action'] = $this->input->post('submit'); #retrieve the action depending on the submit name
$this->load->view('view', $data);
Now, you will get the $action in the view and show the form depending upon it. Hope it helps you.
I'm playing for about 2 days now and can't make this out. I'm working in codeigniter 2.1.0. and I want to submit a form that is written in HTML. I don't want to use the CI form helper.
The reason is because I'm dynamically with JavaScript adding things in the form. When a user clicks an item then it's added to the form. Now when the user clicks the submit button all the items I added should be sent in a POST request, but my POST is totally empty.
Now I noticed that the POST only gets sent when I use form_input() from the CI form_helper.
Is it possible to just submit a normal plain HTML form without using the form helper?
Is it possible to just submit a normal plain HTML form without using the form helper?
Yes. The actual submit is totally independent to CI, just ensure you use the correct action URI of the form so that the correct controller action is called by the form submit post (I assume your form method is post) request.
You do not need to use the CI form_helper for the submit button. If you mock a form with these you will see that those just generate plain HTML and do nothing magically.
I have a Kohana controller, and a route corresponding to it.
also, i want to make a form that will appear as a ajax modal, when a user clicks a link. The problem is: i want this form to be controlled by a different controller action, and of course, because i am using exactly the same data as in the view using the first controller action, i will have exactly the same parameters (in the second controller action).
The problem is that, having the same parameters and only different actions, my both controlers's routes will point in the same page. So...
How can i make an ajax modal form that will use exactly the same variables that the view in which i am putting the link to the modal form is using? is it indicated to make another controller action?
Thank you!
I guess you just should create 2 different views.
How to reset all the fields in the form on each refresh in CakePHP?
Are you asking how to make Cake not put data into the forms automatically, when using the form helper inside a view? If so, Cake just takes the data inside Controller::$data and uses matching array indeces to field names to populate those fields. To stop this, just set $this->data = null; in your controller's action that corresponds to the view.
As mentioned you can make all form data unreachable by setting $this-data to null.
You can also view the HTML page generated, what names the form elements have, and can selectively unset $this->data['objectName'] or $this->data['objectName']['memberName'].