Ayuda con CJuiTabs

Hola,

En la vista use este codigo y funciona:

$this->widget(‘zii.widgets.jui.CJuiTabs’, array(

‘tabs’=>array(

‘StaticTab 1’=>‘Content for tab 1’,

‘StaticTab 2’=>array(‘content’=>‘Content for tab 2’, ‘id’=>‘tab2’),

),

// additional javascript options for the tabs plugin

‘options’=>array(

‘collapsible’=>true,

),

));

Ahora lo que quiero hacer es que en las prestañas me muestre el contenido formulario User. :-[

Ademas tambien me gustaria saber si se puede combinar los CJuiTabs con un CJuiAccordion u otro y cual seria la forma de hacerlo

Si alguien me puede colaborar lo agradeceria.:-[

con renderPartial es una buena forma (ya lo probaste?):




$this->widget('zii.widgets.jui.CJuiTabs', array(

'tabs'=>array(

'StaticTab 1'=>$this->renderPartial('_viewDelFormularioUsuario',array(),true),

'StaticTab 2'=>array('content'=>'Content for tab 2', 'id'=>'tab2'),

),

// additional javascript options for the tabs plugin

'options'=>array(

'collapsible'=>true,

),

));



Tambien lo puedes hacer via AJAX: http://www.yiiplayground.cubedwater.com/index.php?r=UiModule/jui/ziiTab

Y esa misma respuesta te sirve para tu segunda pregunta (yo lo haria via AJAX)

Saludos

Hola, ::)

Gracias por tu respuesta,

Ya habia tratado y se muestra el siguiente error:

SiteController no ha podido encotrar la vista "user" solicitada.

Eso es porque quizas estas intentando mostrar una VIEW que no pertenece al controlador donde estan los TABS. Si ese es el caso, te recomiendo utilices el siguiente ALIAS:




// lo siguiente quiere decir:

// render la view que se llama formulariouser y que 

// se encuentra en PROTECTED/VIEWS/USER/ 

renderPartial('application.views.user.formulariouser'); 



Que pena :-[

pero no me funciona :huh:

te voy dar un esquema de lo que manejo en mi aplicacion:

  1. Los forms, models, modules, controllers y crud los genere por medio de gii.

  2. La estructuara de las carpertas es la siguiente:

C:\xammp\htdocs\prueba\protected\views y dentro estan las siguientes carpetas:

site

layouts

user

y este archivo:

user.php

C:\xammp\htdocs\prueba\protected\views\user y dentro hay:

_form.php

_search.php

_view.php

admin.php

create.php

index.php

update.php

view.php

Gracias por su colaboracion :-[

Donde tienes el view de los tabs? en que carpeta?

Hola

:-[ Que pena pasar por tonta :( pero lo que yo hice fue agregar este codigo que en la siguiente ruta:

C:\xampp\htdocs\prueba\protected\views\site\index.php

<?php

$this->widget(‘zii.widgets.jui.CJuiTabs’, array(

'tabs'=&gt;array(


	'User'=&gt;'Probar si funciona',


	'Usuarios'=&gt;'Probar si funciona',


	//panel 3 contains the content rendered by a partial view


	'AjaxTab'=&gt;array('ajax'=&gt;&#036;this-&gt;createUrl('/AjaxModule/ajax/reqTest01')),


	),


	//additional javasscript options for the tabs plugin


	'options'=&gt;array(


		'collapsible'=&gt;true,


	),


));

?>

y el me mustra los tabs en el Home…aunque no se si lo hice de forma correcta :(

Gracias por tu colaboracion

Aqui nadie es tonto Lula y mucho menos alguien que se esfuerza en aprender ;)

:-[ Pero enserio he leido mucho y realmente no entendo en que me estoy equivacando

si pudieras guiarme por el camino correcto, se lo agradeceria mucho :)

El camino es equivocado, está buscando dentro de la carpeta de usuario

Intente lo siguiente


$this->widget('zii.widgets.jui.CJuiTabs', array(

   	'tabs'=>array(

     //note that the  // will make it point to the application.views folder

 	'User'=>$this->renderpartial('//user/_form.php',array('model'=>$model),true),

 	'Usuarios'=>$this->renderpartial('//user',array(),true),

  ),

		//additional javasscript options for the tabs plugin

		'options'=>array(

    			'collapsible'=>true,

  ),

	));



Hola y muchas gracias por su colaboracion y compresión, he seguido los pasos que ustedes me han dado pero sigo presentando el siguiente error,

CException

Descripción

SiteController no ha podido encontrar la vista "/user/_form.php" solicitada.

Archivo Fuente:

C:\xampp\yii\framework\web\CController.php(807)

00795: {

00796: if(($viewFile=$this->getViewFile($view))!==false)

00797: {

00798: $output=$this->renderFile($viewFile,$data,true);

00799: if($processOutput)

00800: $output=$this->processOutput($output);

00801: if($return)

00802: return $output;

00803: else

00804: echo $output;

00805: }

00806: else

00807: throw new CException(Yii::t(‘yii’,’{controller} cannot find the requested view “{view}”.’,

00808: array(’{controller}’=>get_class($this), ‘{view}’=>$view)));

00809: }

00810:

00811: /**

00812: * Renders dynamic content returned by the specified callback.

00813: * This method is used together with {@link COutputCache}. Dynamic contents

00814: * will always show as their latest state even if the content surrounding them is being cached.

00815: * This is especially useful when caching pages that are mostly static but contain some small

00816: * dynamic regions, such as username or current time.

00817: * We can use this method to render these dynamic regions to ensure they are always up-to-date.

00818: *

00819: * The first parameter to this method should be a valid PHP callback, while the rest parameters

Lo siento, mal escritas, su renderPartial ("//user /_form") sin el ". php"

Hola y gracias ahora me muestra esto:

Fatal error: Call to a member function getErrors() on a non-object in C:\xampp\yii\framework\web\helpers\CHtml.php on line 1561

:-[

Es porque no se que pasa el model para las views, así que intenta tener acceso a CModel::getErrors () en una variable que no es un model

Para solucionarlo, deberá enviar a la view la variable correcta

Obs.: Lo siento por mi español, pero estoy tratando de ayudarle

:-[ Hola y gracias por toda tu colaboración, me podrías explicar un poquito mas detallado esto y como se realiza:

CModel::getErrors ()

Si Se Te Dificulta mucho en español lo podrias hacer en ingles si no hay problema

Its easier in english

So, you pass variables to the views in the following way




$this->render('viewToRender',array('variable1'=>$value1,'variable2'=>$value));

//or renderPartial, the first parameter is the view file and the second is an array with all its variables



and to use it in the view file you rendered do something like the following




echo $variable1;



in your case CModel::getErrors() is probably an error genarated by CActiveorm widge, when you use its method


echo $form->errorSummary($model);

so I presume that the $model variable is not set in your view, to do so, you must define it in the controller, something like the following:




$model=MyModel::model();

$this->render('myView',array('model'=>$model));



and then when you call renderPartial do something like


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

:-* Goodnight

I’m sorry, but the truth is that I’m super new to this and am doing my best to learn the truth but I am very clear about your explanation, if you do not mind can you tell me the name of the files I need to modify or need something more specific in my code so that I could help.

Ptt: My English is not that great but seriously do not know how I appreciate your help.

:)

Después de que leí tu post un par de veces me entiende cuál es el problema.

Quieres acceder al Formulario de otro controlador. ¿correcto?

Si es así, usted necesita un ajaxTab, y usted puede hacerlo de esta manera:


'AjaxTab' => array ('ajax' => $this->createUrl('/user/create')),// si desea crear un nuevo usuario

 / / o

 'AjaxTab' => array ('ajax' => $this->createUrl('/user/ update', array ('id' => 1 ))),// si desea actualizar un usuario existente, es esto caso el usuario numero 1

por lo que el código completo sería algo así como:




  $this->widget('zii.widgets.jui.CJuiTabs', array(

 'tabs'=>array(

 'site'=>$this->render('index'),

'UserTab' => array ('user' =>$this->createUrl('/user/ update ', array ('id' => 1 ))),

 ),

 // additional javascript options for the tabs plugin

 'options'=>array(

 'collapsible'=>true,

 ),

 ));



también tiene que renderizar una view diferente en el controlador, cambia la view existente para ‘_abas’ y crear un archivo _abas en views / site / _abas.php

something like


class SiteController extends Controller{

	public function actionIndex(){

   	//your code

   	//cambia el render index por _abas

   	$this->render('_abas',array('....'));//aki

	}

}

Hola,

Gustavo gracias por tu ayuda :lol:

Esto es para las personas que estan aprendiendo Yii como yo espero que les sirva como me sirvio a mi.

"Para ello, cambia el archivo controlador que se encuentra probablemente en

protected/components/Controller.php

cambia el método de inicio si es que existe, y si no crea uno

class Controller extends CController{

    function init(){//crear esto se no existir  


    parent::init();  


    if(Yii::app()-&gt;getRequest()-&gt;isAjaxRequest){  //if the page was loaded by ajax (ajaxTab)  


            &#036;this-&gt;layout=false;//disable the layout  


    }  


    }  

}"

Lo siento se me paso la parte del codigo del CJuiTabs

En la views/site/index agregamos el codigo de CJUITabs:

$this->widget(‘zii.widgets.jui.CJuiTabs’,array(

	'tabs'=&gt;array(


		'Tabla1'=&gt;array('ajax'=&gt;array('/user'),'id'=&gt;&#036;model-&gt;id),


		'Tabla2'=&gt;array('ajax'=&gt;array('/user/create'),'id'=&gt;&#036;model-&gt;id),


		'Usuarios'=&gt;'contenido de la tabla.',


		//panel 3 contains the content rendered by a partial view


		'AjaxTab'=&gt;array('ajax'=&gt;&#036;this-&gt;createUrl('/AjaxModule/ajax/reqTest01')),


		


	),


	//additional javascrip options for the tabs plugin


	'options'=&gt;array(


			


		'collapsible'=&gt;true,


	),


));

Les adjunto una imagen de lo que yo queria hacer en las CJuiTabs.

Ptt: Todavia estoy investigando como agregar un CJuiAccodion en el CJuitabs apenas sepa como subo el codigo.