由于我在此表单中添加了活动复选框,因此我一直在获得奇怪的行为,只能在文本外部单击“提交”按钮,并且在提交表单时,活动字段的已检查状态不会注册,它总是表现为真实。我检查了活动是否是一个保留字,因为行为是如此的时髦,但无济于事。我是个菜鸟吗?
<div class="add-form">
<?= $this->Form->create($member) ?>
<legend><?= __('Edit Member') ?></legend>
<?php
echo $this->Form->control('membership_no');
echo $this->Form->control('password');
echo $this->Form->control('email');
echo $this->Form->control('company_id', ['options' => $companies]);
echo $this->Form->control('terms_agreed');
echo $this->Form->control('change_password');
echo $this->Form->control('active');
?>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
如果在此处进行任何导入,则是我添加活动列的迁移
<?php
use Migrations\AbstractMigration;
class AddActiveToMembers extends AbstractMigration
{
public function change()
{
$table = $this->table('members');
$table->addColumn('active', 'boolean', [
'default' => true,
'null' => false,
]);
$table->update();
}
}
答案 0 :(得分:0)
尝试使用其他字段名称。
'default'=&gt; true可能返回值'1'...删除并检查输出。
那是
<?php
use Migrations\AbstractMigration;
class AddActiveToMembers extends AbstractMigration
{
public function change()
{
$table = $this->table('members');
$table->addColumn('active_col', 'boolean', [
'default' => true,
'null' => false,
]);
$table->update();
}
}
OR
<?php
use Migrations\AbstractMigration;
class AddActiveToMembers extends AbstractMigration
{
public function change()
{
$table = $this->table('members');
$table->addColumn('active', 'boolean', [
'null' => false,
]);
$table->update();
}
}