askbapi
(Askbapi)
May 10, 2012, 11:15am
1
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.
Hi
use
$list = CHtml::listData($models,‘State_id’, ‘State_name’);
echo CHtml::dropDownList(‘state’, $models->state_id, $list, array(‘empty’ => ‘(Select a state’));
Thanks
askbapi
(Askbapi)
May 11, 2012, 9:00am
3
@ 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
shailesh
(Shailesh Makwana990)
May 12, 2012, 5:22am
4
In View For Our Form Just
Instead Of textField Just Write
[color=#1C2837][size=2]echo CHtml::dropDownList(‘state’, $models->state_id,array_merge($list, array(‘empty’ => ‘(Select a state’)));[/size][/color]
askbapi
(Askbapi)
May 12, 2012, 7:14am
5
$list=CHtml::listData(SysState::model()->findAll(), ‘state_id’, ‘state_name’); fixed my problem.
subhash
(Subhash 5c3)
November 8, 2012, 6:51am
7
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.
Saqib
(Saqib Rezwan)
November 26, 2012, 8:04am
8
SUBHASH:
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.
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;
}
}
<?php echo $form->dropDownList($addr,‘cou_id’, CHtml::listData(AccAccount::model()->findAll(‘cou_id’), ‘cou_id’, ‘cou_name’), array(‘empty’=>’–none–’)) ?>
hi
i want to give link in dropdown is it possible…
i want to check email id already present in table if it is
already present then by clicking on email id i have to goto the profile whose email id is present…