我正在后端使用symfony2构建一个应用程序.我正在考虑在前端使用AngularJS,但我还是想使用symfony表单.我已经使用正确的模块和所有内容设置了表单,但是在实际提交数据时会出现问题.
问题
当Symfony呈现表单时,它会将输入'name'属性设置为数组,例如user[username],这是它在提交数据时希望接收数据的格式.我无法弄清楚如何让Angular以这种格式提交数据.这就是我所拥有的:
<body ng-app="formApp" ng-controller="formController">
{{ form_start(form, {'attr':{'id': 'registerForm', 'ng-submit':'processForm()'}}) }}
{{ form_row(form.username, {'attr':{'ng-model':'formData.username'}}) }}
{{ form_row(form.password.first, {'attr':{'ng-model':'formData.password'}}) }}
{{ form_row(form.password.second) }}
{% for address in form.userAddresses %}
{{ form_row(address.postalCode, {'attr':{'ng-model':'formData.postalCode'}}) }}
{% endfor %}
<div><input type="submit" value="Save" /></div>
{{ form_end(form) }}
</body>
Run Code Online (Sandbox Code Playgroud)
和控制器:
function formController($scope, $http) {
$scope.formData = {};
$scope.processForm = function() {
$http({
method : 'POST',
url : submit,
data : $.param($scope.formData),
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.success(function(data) {
alert(data.message);
});
}; …Run Code Online (Sandbox Code Playgroud) 我已经阅读了很多关于这个错误的回答问题,但没有一个答案似乎能帮我解决问题.
我得到的错误是
#1215 - Cannot add foreign key constraint
Run Code Online (Sandbox Code Playgroud)
当我这样做时show engine innodb status,它给了我这个信息:
在引用的表中找不到索引,其中引用的列显示为第一列,或者表中的列类型与引用的表不匹配约束.请注意,使用> = InnoDB-4.1.12创建的表中ENUM和SET的内部存储类型已更改,旧表中的此类列不能被新表中的此类列引用.
以下是涉及的表(我正在创建一个创建脚本,并且在执行sql期间出现错误)
CREATE TABLE IF NOT EXISTS customer_type (
customer_type_id int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(128) NOT NULL,
sort int(11) NOT NULL,
is_active tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (customer_type_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS location (
location_id int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(200) NOT NULL,
email varchar(255) DEFAULT NULL,
phone varchar(32) DEFAULT NULL,
address …Run Code Online (Sandbox Code Playgroud) 我一直在使用Laravel Excel以 csv 格式导出数据,到目前为止效果非常好。现在我需要以 xlsx 格式导出,以便可以在某些列中包含下拉列表。我已经看过这个问题,但看起来这是针对旧版本的 Laravel Excel 的。我还查看了文档中解释扩展包的页面,但我似乎无法弄清楚如何在导出数据时将下拉列表添加到列中。
这是我的导出类的简化版本:
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
class ActionItemExport implements FromCollection, WithHeadings, WithStrictNullComparison
{
public function collection()
{
return $this->getActionItems();
}
public function headings(): array
{
$columns = [
'Column 1',
'Column 2',
'Column 3',
'Column 4',
'Column 5',
'Column 6',
'Column 7'
];
return $columns;
}
private function getActionItems()
{
$select = 'column1, column2, column3, column4, column5, column6, column7';
$query = \DB::table('action_items')->select(\DB::raw($select)); …Run Code Online (Sandbox Code Playgroud) 我想在 postgresql 中插入时间数据类型,其中包括时区并了解夏令时。这就是我所做的:
CREATE TABLE mytable(
...
start_time time(0) with time zone,
end_time time(0) with time zone
)
INSERT INTO mytable(start_time, end_time)
VALUES(TIME '08:00:00 MST7MDT', TIME '18:00:00 MST7MDT')
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
时间类型的输入语法无效:“08:00:00 MST7MDT”
如果我使用“MST”而不是“MST7MDT”,它就可以工作,但我需要它了解夏令时。我还尝试使用“美国/埃德蒙顿”作为时区,但出现了同样的错误。
插入带有时区和 DST 的时间值(不是时间戳)的正确方法是什么?
编辑:我实际上想使用“美国/埃德蒙顿”语法
php ×2
angularjs ×1
datetime ×1
dst ×1
excel ×1
foreign-keys ×1
forms ×1
indexing ×1
javascript ×1
laravel ×1
mysql ×1
postgresql ×1
sql ×1
symfony ×1
timezone ×1