Welcome Guest, Not a member yet? Register   Sign In
Suggestions for change in form_open.
#1

[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">
and NOT as
Code:
<form action="http://localhost/envis_ci/index.php/[javascript]:doWork()" method="post" accept-charset="utf-8" name="myform" id="myform">
For that, I made a small change in form_helper file. Now it is
Code:
if ($action && strpos($action, '://') === FALSE)
  {
   $exceptionaction = $action; // This has been added
   $action = $CI->config->site_url($action);
  }
  /** The below three lines have been added **/
  if($exceptionaction && strpos($exceptionaction, "::") !== FALSE)
  {
   $action = preg_replace("/\:\:(.)/", "$1", $exceptionaction);
  }
(Please check the form_helper file in the systems/helper folder.
I need your humble suggestions.
Vijay
N.B Please read [javascript] as javascript in code.
#2

[eluser]Aken[/eluser]
You don't want Javascript in a form's action attribute. That's not what it's meant for.




Theme © iAndrew 2016 - Forum software by © MyBB