Php 如何在zend framework 2的zfcuser模块中启用注册表上的用户名字段?

Php 如何在zend framework 2的zfcuser模块中启用注册表上的用户名字段?,php,zend-framework2,zend-form,zfcuser,Php,Zend Framework2,Zend Form,Zfcuser,我在zend framework2中使用zfc用户模块对用户进行身份验证,但它在注册表中未显示用户名字段,但未显示用户名字段并给出错误: Statement could not be executed (23000 - 1048 - Column 'username' cannot be null) 这是我的注册。phtml: <h1>Registration</h1> <?php if (!$this->enableRegistration) { pr

我在zend framework2中使用zfc用户模块对用户进行身份验证,但它在注册表中未显示用户名字段,但未显示用户名字段并给出错误:

Statement could not be executed (23000 - 1048 - Column 'username' cannot be null)
这是我的注册。phtml:

<h1>Registration</h1>

 <?php
if (!$this->enableRegistration) {
print "Registration is disabled";
return;
}
 $form = $this->registerForm;
$form->prepare();
$form->setAttribute('action', $this->url('zfcuser/register'));
$form->setAttribute('method', 'post');
?>

<?php echo $this->form()->openTag($form) ?>
<dl class="zend_form">
<?php foreach ($form as $element): ?>
    <?php if (!$element instanceof Zend\Form\Element\Button): ?>
        <dt><?php echo $this->formLabel($element) ?></dt>
    <?php endif ?>
    <?php if ($element instanceof Zend\Form\Element\Button): ?>
        <dd><?php echo $this->formButton($element) ?></dd>
    <?php elseif ($element instanceof Zend\Form\Element\Captcha): ?>
        <dd><?php echo $this->formCaptcha($element) . $this->formElementErrors($element) ?></dd>
    <?php else: ?>
        <dd><?php echo $this->formInput($element) . $this->formElementErrors($element) ?></dd>
    <?php endif ?>
<?php endforeach ?>
</dl>
<?php if ($this->redirect): ?>
    <input type="hidden" name="redirect" value="<?php echo $this->escapeHtml($this->redirect) ?>" />
<?php endif ?>
<?php echo $this->form()->closeTag() ?>
注册

检查您的
config/autoload/zfcuser.global.php
,并将值更改为true:

     /** 
     * Enable Username
     *
     * Enables username field on the registration form, and allows users to log
     * in using their username OR email address. Default is false.
     *
     * Accepted values: boolean true or false
     */
    'enable_username' => true,
现在你应该可以看到那个区域了

编辑:状态字段位于同一文件中

     /**
     * Enable user state usage
     * 
     * Should user's state be used in the registration/login process?
     */
    'enable_user_state' => false,

如果您希望它位于表单的add true else false中。

谢谢,我尝试了此操作,但无法执行此错误声明(23000-1048-列“状态”不能为空)。您能帮助解决此错误吗?我编辑了答案。您可能需要查看整个配置文件,以了解在出现更多字段问题时可以启用或禁用什么。谢谢,我根据您的代码更改了代码,但无法执行另一个error exist语句(23000-1048-列“user_id”不能为空)如何删除此警告?此警告很奇怪您确定您可能配置了zfc吗?您是否覆盖了一些zfc内容?您的用户id字段是否具有自动增量?