[英]how to enable username field on registration form in zfcuser module of zend framework 2?
我在zend framework2中使用zfc用戶模塊對用戶進行身份驗證,但是在注冊表單中未顯示用戶名字段,但未顯示用戶名字段並給出錯誤:
Statement could not be executed (23000 - 1048 - Column 'username' cannot be null)
這是我的registration.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,
如果要在表單中添加,則為true,否則為false。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.