如何将staff_name列保存为CakePHP中的其他列?
我正在制作账本应用程序,以消除文书工作 但是制造简单的积垢,有一个问题 其他列可以,但无法保存一列 你能看看这个吗 我只是在添加、编辑、删除和查看ctp文件 随着烘焙命令的生成 并且控制器也是通过bake命令制作的 我只是把POST方法改为GET方法 尝试如何将staff_name列保存为CakePHP中的其他列?,php,mysql,database,cakephp,Php,Mysql,Database,Cakephp,我正在制作账本应用程序,以消除文书工作 但是制造简单的积垢,有一个问题 其他列可以,但无法保存一列 你能看看这个吗 我只是在添加、编辑、删除和查看ctp文件 随着烘焙命令的生成 并且控制器也是通过bake命令制作的 我只是把POST方法改为GET方法 尝试 重新生成表列时,请确保使用了正确的名称 确保我使用了正确的蛋糕语法 在实体中添加可访问的 add.ctp 我想选择表格来限制类别 LedgersController.php 公共函数编辑($id=null){ //返回GET数据(在u
- 重新生成表列时,请确保使用了正确的名称
- 确保我使用了正确的蛋糕语法
- 在实体中添加可访问的
我想选择表格来限制类别
LedgersController.php
公共函数编辑($id=null){
//返回GET数据(在url中)
$ledger=$this->Ledgers->get($id);
//这只是一个帖子-------------
如果($this->request->is(['patch','post','put'])){
$ledger=$this->Ledgers->patchEntity(
$ledger,$this->request->getData());
如果($this->Ledgers->save($ledger)){
$this->Flash->success(
__(“分类账已保存”);
返回$this->redirect(
['action'=>'index']);
}
$this->Flash->error(
__(“无法保存分类账”);
}
//职位
$this->set(压缩(“分类账”);
}
分贝
所有代码都在这里
表名被弄乱了。
我很困惑,因为列
staff\u id
由于条件原因无法使用,
所以我创建了一个新的专栏worker
,并替换了这个,但它很复杂。
当我将代码与staff\u id
我也被和
表名被弄乱了。
我很困惑,因为列staff\u id
由于条件原因无法使用,
所以我创建了一个新的专栏worker
,并替换了这个,但它很复杂。
当我将代码与staff\u id
我也被和
尝试此选择选项可能会有所帮助
添加.ctp
<div class="ledgers form large-9 medium-8 columns content">
<?= $this->Form->create($ledger) ?>
<fieldset>
<legend><?= __('Add Ledger') ?></legend>
<?php
echo $this->Form->control('customer_name');
echo $this->Form->control('customer_adress');
echo $this->Form->control('customer_tel1');
echo $this->Form->control('customer_tel2');
echo $this->Form->control('staff_name', [
'type' => 'select',
'placeholder' => __('staff_name'),
'label' => __('staff_name'),
'empty' => __('(Choose Type)'),
'value' => $ledger->staff_name,
'options' => [
['value' => 'Fukuda', 'text' => __('Fukuda')],
['value' => 'Hayasi', 'text' => __('Hayasi')],
['value' => 'Seki', 'text' => __('Kubo')],
['value' => 'Kubo', 'text' => __('Kubo')]
]
]);
echo $this->Form->control('work_category ', [
'type' => 'select',
'placeholder' => __('work_category '),
'label' => __('work_category'),
'empty' => __('(Choose Type)'),
'value' => $ledger->work_category ,
'options' => [
['value' => 'preview', 'text' => __('preview')],
['value' => 'build', 'text' => __('build')],
['value' => 'repair', 'text' => __('repair')],
['value' => 'etc', 'text' => __('etc')]
]
]);
echo $this->Form->control('content');
echo $this->Form->control('reserved');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
此样式也有助于轻松编辑。尝试此选择选项可能会有所帮助
添加.ctp
<div class="ledgers form large-9 medium-8 columns content">
<?= $this->Form->create($ledger) ?>
<fieldset>
<legend><?= __('Add Ledger') ?></legend>
<?php
echo $this->Form->control('customer_name');
echo $this->Form->control('customer_adress');
echo $this->Form->control('customer_tel1');
echo $this->Form->control('customer_tel2');
echo $this->Form->control('staff_name', [
'type' => 'select',
'placeholder' => __('staff_name'),
'label' => __('staff_name'),
'empty' => __('(Choose Type)'),
'value' => $ledger->staff_name,
'options' => [
['value' => 'Fukuda', 'text' => __('Fukuda')],
['value' => 'Hayasi', 'text' => __('Hayasi')],
['value' => 'Seki', 'text' => __('Kubo')],
['value' => 'Kubo', 'text' => __('Kubo')]
]
]);
echo $this->Form->control('work_category ', [
'type' => 'select',
'placeholder' => __('work_category '),
'label' => __('work_category'),
'empty' => __('(Choose Type)'),
'value' => $ledger->work_category ,
'options' => [
['value' => 'preview', 'text' => __('preview')],
['value' => 'build', 'text' => __('build')],
['value' => 'repair', 'text' => __('repair')],
['value' => 'etc', 'text' => __('etc')]
]
]);
echo $this->Form->control('content');
echo $this->Form->control('reserved');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
这种样式也有助于您轻松编辑。您对
和
的混淆是什么?我以为这是数据,td是标题。它们的命名不像其他一些表标记那样直观,比如
和
,所以它们很容易混淆
实际上代表“表头”和
代表“表数据”。您对
和
的混淆是什么?我以为这是数据,td是标题。它们的命名不像其他一些表标记那样直观,比如
和
,所以它们很容易混淆
实际上代表“表格标题”和
代表“表格数据”。非常感谢!!真是太。。。很漂亮。在您的代码中,(类型、占位符、标签和空)将包含在选择中,所以我只使用了空和选项。非常感谢!!真是太。。。很漂亮。在您的代码中,(类型、占位符、标签和空)将包含在选择选项中,所以我只使用了空和选项。
<th scope="col"><?= $this->Paginator->
sort('id') ?></th>
<th scope="col"><?= $this->Paginator->
sort('customer_name') ?></th>
<th scope="col"><?= $this->Paginator->
sort('customer_tel1') ?></th>
<th scope="col"><?= $this->Paginator->
sort('customer_tel2') ?></th>
<th scope="col"><?= $this->Paginator->
sort('staff_name') ?></th>
<th scope="col"><?= $this->Paginator->
sort('work_category') ?></th>
<th scope="col"><?= $this->Paginator->
sort('created') ?></th>
<th scope="col"><?= $this->Paginator->
sort('reserved') ?></th>
<th scope="col"><?= $this->Paginator->
sort('modified') ?></th>
<th scope="col" class="actions">
<?= __('Actions') ?></th>
<?php foreach ($ledgers as $ledger): ?>
<tr>
<td><?= $this->Number->format($ledger->id) ?></td>
<td><?= h($ledger->customer_name) ?></td>
<td><?= h($ledger->customer_tel1) ?></td>
<td><?= h($ledger->customer_tel2) ?></td>
<td><?= h($ledger->staff_name) ?></td>
<td><?= h($ledger->work_category) ?></td>
<td><?= h($ledger->created) ?></td>
<td><?= h($ledger->reserved) ?></td>
<td><?= h($ledger->modified) ?></td>
<div class="ledgers form large-9 medium-8 columns content">
<?= $this->Form->create($ledger) ?>
<fieldset>
<legend><?= __('Add Ledger') ?></legend>
<?php
echo $this->Form->control('customer_name');
echo $this->Form->control('customer_adress');
echo $this->Form->control('customer_tel1');
echo $this->Form->control('customer_tel2');
echo $this->Form->control('staff_name', [
'type' => 'select',
'placeholder' => __('staff_name'),
'label' => __('staff_name'),
'empty' => __('(Choose Type)'),
'value' => $ledger->staff_name,
'options' => [
['value' => 'Fukuda', 'text' => __('Fukuda')],
['value' => 'Hayasi', 'text' => __('Hayasi')],
['value' => 'Seki', 'text' => __('Kubo')],
['value' => 'Kubo', 'text' => __('Kubo')]
]
]);
echo $this->Form->control('work_category ', [
'type' => 'select',
'placeholder' => __('work_category '),
'label' => __('work_category'),
'empty' => __('(Choose Type)'),
'value' => $ledger->work_category ,
'options' => [
['value' => 'preview', 'text' => __('preview')],
['value' => 'build', 'text' => __('build')],
['value' => 'repair', 'text' => __('repair')],
['value' => 'etc', 'text' => __('etc')]
]
]);
echo $this->Form->control('content');
echo $this->Form->control('reserved');
?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>