dqroktbn005028 2016-10-04 10:25
浏览 33

如何在ZF 1中显示两个密码字段? [重复]

This question already has an answer here:

So, I got a small problem with Zend Framework 1.12 and I don't know how to solve it:

I got a userform for a rather simple registration. However, I want it to display 2 password fields, one for the password and one for the confirmation. Obviously, I want it to be password fields instead of text fields, so I did the following:

public function init()
{
    $this->setName('user');

    ... few fields which do work fine ...

    $password = new Zend_Form_Element_Password('password');
    $password->setLabel('Password')
        ->setRequired(true);

    $passwordConfirm = new Zend_Form_Element_Password('password');
    $passwordConfirm->setLabel('Confirm password')
                    ->setRequired(true);

    $submit = new Zend_Form_Element_Submit('submit');
    $submit->setAttrib('id', 'submitbutton');

    $this->addElements(array($id, $username, $prename, $surname, $password, $passwordConfirm, $email, $gender, $submit));
}

However, the form looks like this once it's printed:

Dis ma form

When I swap $password and $passwordConfirm, the label of $password is shown. So I assume each passwordfield overwrites the previous one.

How can I display both passwordfields in one form? Or do I really have to build 2 forms for this purpose?

</div>
  • 写回答

1条回答 默认 最新

  • dpmp9359 2016-10-04 10:29
    关注

    You should choose different name for password confirm, eg

    $passwordConfirm = new Zend_Form_Element_Password('passwordconfirm');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计