Render Module View Inside CJuiDialog

Hi,

I’m using the user module to provide simple user management. The user module provides a “login” view. I want to render the login view so I can show the view inside a modal dialog (in a similar manner to stay.com).

What’s the correct approach to rendering a modules view like this? I’ve tried calling render with the modules view name from inside an application view and inside a simple widget I created. No matter what path I provide to the view e.g. “/module/user/views/user/login” I can’t get the view to render.

Any help much appreciated,

Paul.

try a look here Cookbook: Adding login form to each page

Thanks, that doesn’t really answer the question though. That article is rendering the application view “login”, I’m trying to explicitly render a view that’s contained within a module. I assumed that appending the module path in front of the view e.g. “/module/user/views/user/login” would render the view but it doesn’t.

Thanks,

Paul.

Sounds like what you need is a login widget. This widget could even be packaged with the user module. Controller actions are not meant to be embedded in other actions except via AJAX. Widgets are meant to be embedded though

Hi jonah,

Thanks for the reply. My original approach was to create a login / register widget which was modelled on the stay.com widget. There were two problems with using a widget though (that wasn’t packaged as part of the user module). Firstly I couldn’t get renderpartial to work, then I couldn’t get the view name to work as I’ve outlined above (I just resorted to using render at this point).

Please tell me what I’m doing wrong. The only approach I can see working at the moment is to use the model and controller from the “user” module and create a view inside the widget - that seems completely wrong though.

Help!

Paul.

You can use CJuiDialog for open the modal dialog box for login.

It requires you to create a div with an id.

You can implement an action in site/login for fill the modal box.

It should be something like that:




<?php CHtml::linkButton(

    'login', 

    '#', 

    'onClick'=>CHtml::ajax(

         url=>array('site/login'),

         'success'=>'function (data){

			$('#dialogLogin').html(data); 

			div.find('form').submit(/*once again login*/);

			#dialogLogin.dialog("open");'

    ));?>



You should have in the page a CJuiDialog with id dialogLogin.

This is a starting point, you have still to manage the answare from the login action.

I’m try to find solution for similar functionality. Looking to create login window using zii.widgets.jui.CJuiDialog





<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog', array(

  'id'=>'mydialog',

  // additional javascript options for the dialog plugin

  'options'=>array(

      'title'=>'Please login',

      'autoOpen'=>true,

      ),

  ));


  //echo 'dialog content here';

  $this->renderPartial('/site/pages/about'); // works fine. this is a static page without model

  //$this->renderPartial('/user/login'); // Don't work

  //$this->renderPartial('/site/contact'); // Also don't work with error Undefined variable: model.


$this->endWidget('zii.widgets.jui.CJuiDialog');

    

// the link that may open the dialog

echo CHtml::link('open dialog', '#', array(

   'onclick'=>'$("#mydialog").dialog("open"); return false;',

));

    

?>




Any ideas how I can use CJuiDialog to render other controllers view?

hi, try this





<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog', array(

  'id'=>'mydialog',

  // additional javascript options for the dialog plugin

  'options'=>array(

      'title'=>'Please login',

      'autoOpen'=>true,

      ),

  ));

  //define the model

  $model= new loginForm;

  //echo 'dialog content here';

  $this->renderPartial('/user/login',array('model'=>$model));


$this->endWidget('zii.widgets.jui.CJuiDialog');

    

// the link that may open the dialog

echo CHtml::link('open dialog', '#', array(

   'onclick'=>'$("#mydialog").dialog("open"); return false;',

));

    

?>




jembroz :)

Welcome to the forum, jembroz!

My congrats for your first post, as is an aswering post and not a question one!

Great Job Jembroz! I really needed something like that!