微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

用october cms插入数据库postgres

如何解决用october cms插入数据库postgres

大家好,我是 10 月 cms 的新手,我正面临着让我头晕目眩的麻烦。我有一个用户那里获取数据的表单,我正在使用构建器。 这是我的表格:

{% put sudah %}{% partial "expert/yes"  %}{% endput %}

{% put styles %}
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;600;700&display=swap"> 
  
{% endput %}


<div class="text-center bg-primary">
    <h4 class="text-white my-auto py-5 title-menu">Expert Registration Form</h4>
</div>
 <div class="opening" id="first-menu">
    <p>Expert Registration Form</p>
    <button onclick="changeMenu()" class="btn btn-primary">
        Bergabung
        &nbsp;&nbsp;&nbsp;&nbsp;
        <i class="fa fa-arrow-right" aria-hidden="true"></i>
    </button>
</div>


 <div class="tab-content d-none pb-4" id="second-menu">
   <div class=" container">
        <div class="head-menu">
            <p>Have you registered yet ?</p>
        </div>
        <div class="p-2">
            <div class="form-check my-3">
                <input class="form-check-input" type="radio" name="radioPick" id="yes" value="yes" checked>
                <label class="form-check-label" for="radioPick">Yes</label>
            </div>
            <div class="form-check my-3">
                <input class="form-check-input" type="radio" name="radioPick" id="no" value="no">
                <label class="form-check-label" for="radioPick">No</label>
            </div>
        </div> 
        <div class="btn-next mt-4">
            <button onclick="secondMenu()" class="btn btn-primary">Next</button>
        </div>
   </div>
 </div>
 
 <div id="yes" class="d-none">
    {% placeholder yes%}
 </div>
{% put scripts %}
   <script>
        const changeMenu = () => {
            $( "#first-menu" ).addClass('d-none');
            $( "#second-menu" ).removeClass('d-none');
        }


        const secondMenu = () => {
          let radio = $('input[name=radioPick]:checked').val()
          $( "#second-menu" ).addClass('d-none');

          if(radio === 'yes'){
                $( "#yes" ).removeClass('d-none');
            }
         }

   </script>
{% endput %}

如果是,则出现是的形式 这是形式:

<form method="POST" action="" accept-charset="UTF-8" enctype="multipart/form-data" id="example" class="something">

<input type="hidden" name="handler" value="onSave">

{{ form_token() }}
{{ form_sessionKey() }}

<div class="tab-content py-4" id="second-menu">
    <div class="container">
        <div class="content-letter tab">
            <p class="title-letter">Please Fill This Form</p>

        <div class="content-letter tab">
            <div class="mt-3">
                <div class="form-group row">
                    <div class="col-12">
                        <label class="text-dark font-weight-bold">Nama</label>
                        <input type="text" class="form-control" placeholder="Name" name="name"
                            id="name" required>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-12">
                        <label class="text-dark font-weight-bold">Phone</label>
                        <input type="number" class="form-control" placeholder="Phone" name="phone"
                            id="phone" required>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-12">
                        <label class="text-dark font-weight-bold">Signature</label>
                        <div class="row">
                            <div class="col-9 col-md-10">
                                <div class="custom-file">
                                    <input type="file" id="signature" class="custom-file input-file"
                                        name="signature" accept="image/x-png,image/gif,image/jpeg">
                                    <label id="label-sign" for="sign"
                                        class="custom-file-label label-files">Upload Signature</label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <button
            id="btn-okay"
            type="submit"
            data-request="onSave"
            data-hotkey="ctrl+s,cmd+s"
            data-load-indicator="Creating New..."
            class="btn btn-primary">
            Join
        </button>
    </div>
</div>

</form>

代码部分我写了这个函数

function onSave() {
$expert= new Expert();
$model = new \Models\Expert;

$expert->name = Input::get('name');
$expert->phone = Input::get('phone');
$expert->sign= Input::file('signature');

$expert->save();
return Redirect::back;

//or even this one
/*$nama = Input::get('name');
$phone = Input::get('phone');
$sign = Input::file('signature');

DB::table('expert')->insert([
    'name' => $name,'phone' => $phone,'sign' => $sign
]);
return Redirect::back;*/

}

不要忘记我在专家模型中附加模型:

 public $attachOne = [
    'signature' => 'System\Models\File'
];

请帮帮我,我的代码有什么问题?谢谢

解决方法

检查 documents 使用模型。你的 php 函数应该是:

use Author\Plugin\Models\Expert;
function onSave() {
    $expert= new Expert;

    $expert->name = Input::get('name');
    $expert->phone = Input::get('phone');
    $expert->sign = Input::file('signature');

    $expert->save();
    return Redirect::back;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?