I have two table branch and other state. Branch table has state_id link with state table by state_id.
Two model are created for both tables. Now I want to create a dropdown list box with all state anem present in State table thru Branch model to display it in a form.
Page 1 of 1
How to create dropdown list box
#2
Posted 10 May 2012 - 06:20 AM
Hi
use
$list = CHtml::listData($models,'State_id', 'State_name');
echo CHtml::dropDownList('state', $models->state_id, $list, array('empty' => '(Select a state'));
Thanks
use
$list = CHtml::listData($models,'State_id', 'State_name');
echo CHtml::dropDownList('state', $models->state_id, $list, array('empty' => '(Select a state'));
Thanks
Yii Help
http://phpyiiwebapp.wordpress.com/
http://phpyiiwebapp.wordpress.com/
#3
Posted 11 May 2012 - 04:00 AM
@ Pravin Gajera
Thanks for your reply.
I still have problem in getting data through "$list = CHtml::listData($models,'State_id', 'State_name');". It is returning empty array
Thanks for your reply.
I still have problem in getting data through "$list = CHtml::listData($models,'State_id', 'State_name');". It is returning empty array
Bapi Roy
#4
Posted 12 May 2012 - 12:22 AM
In View For Our Form Just
Instead Of textField Just Write
echo CHtml::dropDownList('state', $models->state_id,array_merge($list, array('empty' => '(Select a state')));
Instead Of textField Just Write
echo CHtml::dropDownList('state', $models->state_id,array_merge($list, array('empty' => '(Select a state')));
#5
Posted 12 May 2012 - 02:14 AM
$list=CHtml::listData(SysState::model()->findAll(), 'state_id', 'state_name'); fixed my problem.
Bapi Roy
#7
Posted 08 November 2012 - 01:51 AM
I am new to this yii framework and Now i am working on the login page i stored the username and password in the login table and i want to retrieve these values in authenticate() which is present UserIdentity.php
my table name is login with two columns username password
my Model name is LoginForm.php
and
my register model name is Register.php
through this i stored the values into the database
my code in authentication() is
public function authenticate()
{
$username = strtolower($this->username);
$password = $this->password;
$user = Register::model()->find('username=:username and password=:password',
array(
':username'=>$username,
':password'=>$password,
));
if ($user === null)
$this->errorCode = self::ERROR_USERNAME_INVALID;
else
return $this->errorCode == self::ERROR_NONE;
}
so please help me in retrieving these values correctly.
my table name is login with two columns username password
my Model name is LoginForm.php
and
my register model name is Register.php
through this i stored the values into the database
my code in authentication() is
public function authenticate()
{
$username = strtolower($this->username);
$password = $this->password;
$user = Register::model()->find('username=:username and password=:password',
array(
':username'=>$username,
':password'=>$password,
));
if ($user === null)
$this->errorCode = self::ERROR_USERNAME_INVALID;
else
return $this->errorCode == self::ERROR_NONE;
}
so please help me in retrieving these values correctly.
#8
Posted 26 November 2012 - 03:04 AM
SUBHASH, on 08 November 2012 - 01:51 AM, said:
I am new to this yii framework and Now i am working on the login page i stored the username and password in the login table and i want to retrieve these values in authenticate() which is present UserIdentity.php
my table name is login with two columns username password
my Model name is LoginForm.php
and
my register model name is Register.php
through this i stored the values into the database
my code in authentication() is
public function authenticate()
{
$username = strtolower($this->username);
$password = $this->password;
$user = Register::model()->find('username=:username and password=:password',
array(
':username'=>$username,
':password'=>$password,
));
if ($user === null)
$this->errorCode = self::ERROR_USERNAME_INVALID;
else
return $this->errorCode == self::ERROR_NONE;
}
so please help me in retrieving these values correctly.
my table name is login with two columns username password
my Model name is LoginForm.php
and
my register model name is Register.php
through this i stored the values into the database
my code in authentication() is
public function authenticate()
{
$username = strtolower($this->username);
$password = $this->password;
$user = Register::model()->find('username=:username and password=:password',
array(
':username'=>$username,
':password'=>$password,
));
if ($user === null)
$this->errorCode = self::ERROR_USERNAME_INVALID;
else
return $this->errorCode == self::ERROR_NONE;
}
so please help me in retrieving these values correctly.
Try this :
class UserIdentity extends CUserIdentity
{
public $_id;
public function authenticate()
{
$username=strtolower($this->username);
$user=Register::model()->find('LOWER(username)=?',array($username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if(!$user->validatePassword($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->username=$user->username;
$this->errorCode=self::ERROR_NONE;
}
return $this->errorCode==self::ERROR_NONE;
}
public function getId()
{
return $this->_id;
}
}
#9
Posted 05 December 2012 - 02:21 AM
<?php echo $form->dropDownList($addr,'cou_id', CHtml::listData(AccAccount::model()->findAll('cou_id'), 'cou_id', 'cou_name'), array('empty'=>'--none--')) ?>
Share this topic:
Page 1 of 1

Help












