我试着理解为什么我的表单动作没有把我带到控制器......我按下模态上的更新按钮,它应该将模态的信息更新到数据库......当我按下它时,没有任何反应,没有错误,没有消息,它只是关闭模态,就是这样。帮助PLS !!!这是我的代码:
FORM
<div id="modal1" class="modal modal-fixed-footer">
<div class="modal-content">
<h3 class="center-align">Actualizar registro</h3>
<div class="row">
<form class="col s12" id="update_form" enctype="multipart/form-data" method="post" action ="<?= base_url()?>admin/update_politic">
<div class="row">
<div class="input-field col s6">
<input id="update_name" type="text" name="name" class="validate">
<label for="first_name">Nombre</label>
</div>
<div class="input-field col s6">
<input id="update_last_name" name="lastname" type="text" class="validate">
<label for="last_name">Apellido</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input id="update_side" type="text" name="side" class="validate">
<label for="partido">Partido</label>
</div>
<div class="input-field col s6">
<input id="update_charge" type="text" name="charge" class="validate">
<label for="cargo">Cargo</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<div class="file-field input-field no-margin-top">
<div class="btn light-blue darken-4">
<span>Animación/Imagen</span>
<input type="file" name="animation_file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" id="animation" name="animation" type="text">
</div>
</div>
</div>
<div class="input-field col s6">
<select id="update_section" name="section" autocomplete="off">
<option value="" disabled selected>Seleccione una opción</option>
<option value="1">Presidencia</option>
<option value="2">Senadores</option>
<option value="3">Diputados</option>
</select>
<label>Sección</label>
</div>
</div>
<input type="hidden" name="update_politic_hide" id="update_politic_hdn" value="">
<div class="row">
<button class="btn waves-effect waves-light light-blue darken-4" id="submit_update" type="submit" name="action">Actualizar</button>
</div>
</form>
</div>
</div>
CONTROLLER
public function update_politic(){
echo "entreeeeeeee";
if (empty($_FILES['animation_file']['name']))//Compruebo si el array $_files no tiene ningun valor en su elemento name
{
//El metodo obtenerImagen me retorna los valores de dicho id
$data = $this->politic->get_file_name($this->input->post('update_politic_hide'));
$imagen = $data->POLITIC_FILE;//recupero el nombre de la imagen
}
else{
//en caso exista algun valor se procede a subir
$this->load->library("upload");
$config['upload_path'] = "./public/uploads/";
$config['allowed_types'] = "*";
$config['max_size'] = "500000";
$config['max_width'] = "2000";
$config['max_height'] = "2000";
if (!$this->upload->do_upload("animation")) {
$data['uploadError'] = $this->upload->display_errors();
echo $this->upload->display_errors();
}
else {
$file_info = $this->upload->data();
$params["name"] = $this->input->post("name");
$params["lastname"] = $this->input->post("lastname");
$params["side"] = $this->input->post("side");
$params["charge"] = $this->input->post("charge");
$params["animation"] = $file_info['file_name'];
$params["section"] = $this->input->post("section");
if ($params["section"]=="Presidencia") {
$params["section"]=1;
}
if ($params["section"]=="Senadores") {
$params["section"]=2;
}
if ($params["section"]=="Diputados") {
$params["section"]=3;
}
$this->load->model("politic");
$this->politic->update($params);
}
}
}
答案 0 :(得分:0)
试试这个
<?php echo form_open(base_url() . 'admin/update_politic' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));?>
答案 1 :(得分:0)
您已使用base_url()?>admin/update_politic
提交表单。但你还没有提到那个控制器。如果你有管理员控制器,那就没问题了。否则,这就是提交此内容的原因。
答案 2 :(得分:0)
而不是按钮使用&lt; input type = "submit"
value =“提交”class =“您的班级名称”&gt;