Hi everybody,
can anyone tell me how to use yiibootstarp modal in all controller actions,
Currently its working only at
site/index
method.
but I want to use yiibootstarp modal in all controller and their methods.
like this
site/contact , site/login
(e.t.c.)
I am using this code in my views/layouts/main.php:
<p><?php
$this->widget('bootstrap.widgets.TbButton', array(
// 'size' => 'large',
'type'=>'primary',
'label' => 'Register',
'url' => '#register-modal',
'htmlOptions' => array(
'data-toggle' => 'modal',
'onclick' => '$("#error-div").hide();$("#RegisterForm_first_name").focus();'),
)
);
?></p>
In my sitecontroller.php
$this->render('index',array('register_form_model'=>$register_form_model));
in my view/site/index.php
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'LoginForm',
'htmlOptions' => array(
'class' => 'well'),
)
);
?>
<div id="error-div" class="alert alert-block alert-error" style="display:none;">
</div>
<?php echo $form->textFieldRow($login_form_model, 'username', array(
'class' => 'span3'
)
); ?>
<?php echo $form->passwordFieldRow($login_form_model, 'password', array(
'class' => 'span3'
)
); ?>
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType' => 'ajaxSubmit',
'icon' => 'ok',
'label' => 'Submit',
'ajaxOptions' => array(
'success' =>
'function(data){
var obj = $.parseJSON(data);
if(obj.login=="success"){
$("#login-modal").modal("hide");
setTimeout(function(){location.reload(true);},400);
}else{
$("#error-div").show();
$("#error-div").html("");
if("LoginForm_password" in obj){
$("#error-div").html(obj.LoginForm_password[0]+"<br />");
}
if("LoginForm_username" in obj){
$("#error-div").append(obj.LoginForm_username[0]);
}
}
}'),
));
?>
<?php $this->endWidget(); ?>
</div>
<?php $this->endWidget(); ?>
but it works only when url is
http://localhost/yiiFramework/index.php
and not working for other method of sitecontroller like
site/contact , site/login
(e.t.c.)