How to remove the action attribute in the form_open_multipart() in Codeigniter?

前端 未结 1 1055
余生分开走
余生分开走 2021-01-26 06:42

Is there a way that I can remove the action attribute in CodeIgniter?

The code would normally be like this:

form_open_multipart(\'person/add\', $attribut         


        
相关标签:
1条回答
  • 2021-01-26 07:09

    Sure you can but consider:

    1) The action attribute has a meaning and a function, don't know why you want it out

    2) You can always pass it an empty string :

      <?php echo form_open('');?>
    

    or <?php echo form_open_multiaction('');?>

    gives:

      <form action="" method="post">
    

    In case you're really sure about this, just open up the form_helper.php file, located in system/helpers/form_helper.php.

    Pick lines 59 - 65 :

    $action OR $action = $CI->config->site_url($CI->uri->uri_string());
    $form = '<form action="'.$action.'"';
    $form .= _attributes_to_string($attributes, TRUE);
    $form .= '>';
    

    and change line 60 to

    $form = '<form ';
    

    form_open_multiaction() just picks the form_open() and adds the enctype attribute, so you change form_open() and you're set.
    It's up to you now, I still fail to see why an empty action won't suffice to your goals.

    0 讨论(0)
提交回复
热议问题