![]() |
Suggestions for change in form_open. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Suggestions for change in form_open. (/showthread.php?tid=51978) |
Suggestions for change in form_open. - El Forum - 05-25-2012 [eluser]Unknown[/eluser] The form_open function in the form_helper is used to open the form. However, by default, the action is to the current BASE URL, and then to where it is written. E.g. if we type Code: echo form_open('mypage'); then it will interpret it as Code: <form method="post" accept-charset="utf-8" action="http:/example.com/index.php/mypage" /> However, we dont have the option to transfer it to, say javascript:doWork() without the base URL. Hence, I have made a small change in the form_helper file, in which case, if we preceed the parameter with ::, then it will print as it it. i.e, if we give Code: echo form_open('::[javascript]:doWork()', array('name' => 'myform', 'id' => 'myform')); then it will be interpreted as Code: <form action="[javascript]:doWork()" method="post" accept-charset="utf-8" name="myform" id="myform"> Code: <form action="http://localhost/envis_ci/index.php/[javascript]:doWork()" method="post" accept-charset="utf-8" name="myform" id="myform"> Code: if ($action && strpos($action, '://') === FALSE) I need your humble suggestions. Vijay N.B Please read [javascript] as javascript in code. Suggestions for change in form_open. - El Forum - 05-25-2012 [eluser]Aken[/eluser] You don't want Javascript in a form's action attribute. That's not what it's meant for. |