我试图通过调用Zend_Auth
以获取登录用户的用户名来限制下拉菜单中的 1 个选项。代码看起来不错,但它只在下拉菜单中显示 1 个空格。
$auth= Zend_Auth::getInstance();
$user= $auth->getIdentity();
$username = $user->username;
$memberid = $this->createElement('select', 'memberid'); //dropdown menu of member name
$memberid->setLabel('Member Id')
->setRequired(true);
$db_member = new Application_Model_DbTable_Register();
$select = $db_member->select('userid')
->from(array('usertable'))
->where('usertable.username = ?', $username);
$row = $db_member->fetchRow($select);
$memberid->addMultiOption($row['userid']);