Revision #7 has been created by Maurizio Domba Cerin on Feb 2, 2011, 10:28:20 AM with the memo:
removed spaces
« previous (#5) next (#8) »
Changes
Title
unchanged
How to create nice modal login widget with a CJuiDialog
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
user, login, modal, widget
Content
changed
[...]
```php
class UserLoginWidget extends CWidget
{
public $title='User login';
public $visible=true;
public function init()
{[...]
{
$this->renderContent();
}
}
protected function renderContent()
{[...]
$this->controller->redirect($url);
}
}
$this->render('UserLogin',array('form'=>$form));
}[...]
```php
<?php if(Yii::app()->user->isGuest) : ?>
<?php
if($form->getErrors() != null) {
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'userloginwidget',
'cssFile'=>'jquery-ui-1.8.7.custom.css',
'theme'=>'redmond',
'themeUrl'=>Yii::app()->request->baseUrl.'/css/ui',
'options'=>array(
'title'=>'User Login Errors',
'autoOpen'=>true,
'modal'=>true,
'width'=>350,
),
));
}else{
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'userloginwidget',
'cssFile'=>'jquery-ui-1.8.7.custom.css',
'theme'=>'redmond',
'themeUrl'=>Yii::app()->request->baseUrl.'/css/ui',
'options'=>array(
'title'=>'User Login',
'autoOpen'=>false,
'modal'=>true,
'width'=>300,
),
));
}
?>[...]
<?php echo CHtml::activeLabel($form,'username'); ?>
<br/>
<?php echo CHtml::activeTextField($form,'username') ?>
<?php echo CHtml::activeLabel($form,'password'); ?>
<br/>
<?php echo CHtml::activePasswordField($form,'password') ?>
<?php echo CHtml::activeCheckBox($form,'rememberMe'); ?>
<?php echo CHtml::activeLabel($form,'rememberMe'); ?>
<?php echo CHtml::submitButton('Submit'); ?>
<?php echo CHtml::error($form,'password'); ?>
<?php echo CHtml::error($form,'username'); ?>
<?php echo CHtml::endForm(); ?>
<?php $this->endWidget('zii.widgets.jui.CJuiDialog'); ?>
<?php endif; ?>
```[...]
Calling the widget
```php
<?php
$this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'User Llogin', 'url'=>'#','linkOptions'=>array( 'onclick'=>'$("#userloginwidget").dialog("open"); return false;'),
'visible'=>Yii::app()->user->isGuest),
),
));
$this->widget('UserLoginWidget',array('visible'=>Yii::app()->user->isGuest));
?>
```