【问题标题】:Codeigniter add attribute to open_form_multipartCodeigniter 将属性添加到 open_form_multipart
【发布时间】:2017-11-23 00:46:32
【问题描述】:

我们有一个表格可以将产品添加到我们的数据库中。我们在open_form_multipart 中有图片。我们认为问题在于它没有添加我们的属性。

错误:

错误号:1048

列“product_foto”不能为空

插入productsproduct_naamproduct_beschrijvingproduct_categorieophaal_plaatsproduct_fotodate_createddate_updated)值('','','','' , NULL, '2017-06-20', '2017-06-20')

文件名:models/Product_model.php

行号:9

我们的代码在视图中:

<?php
echo $this->session->flashdata('msg');
echo form_open_multipart('name="product_foto"');
echo form_upload('file');
echo form_submit('upload', 'Upload');
?>

【问题讨论】:

    标签: php database forms codeigniter


    【解决方案1】:

    您需要遵循定义表单的约定。

    Documentation

    你的代码应该是:

    $arr = array('name' => 'product_foto');
    echo form_open_multipart('', $arr);
    

    form_open_multipart([$action = ''[, $attributes = array()[, $hidden = 数组()]]])

    参数:

    $action (string) – 表单动作/目标 URI

    string $attributes (array) – HTML 属性

    $hidden (array) - 一个 隐藏字段定义数组返回:HTML 多部分表单 开始标签

    返回类型:字符串

    注意:操作设置为空白,以便表单提交到同一页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-02
      • 2011-04-20
      • 1970-01-01
      • 1970-01-01
      • 2014-08-29
      • 2011-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多