[EXTENSION] EUpdateDialog

Hi!,

I’m using your extension… Nice work… but… Why the “title” poperty is not working?.. I see in the js you hard coded the title of the dialog :unsure:

How can I fix it? (I don’t know about jQuery :( )

BTW, If you answer that, I’ll can “customize” the "delte message"and other strings to internationalize it :)

Thanks in advance…

E.

I fixed it commenting the line 86 in EUpdateDialog.js




  // Open the dialog

85:  $( '#update-dialog' )

86:    //.dialog( { title: dialogTitle } )

87:    .dialog( 'open' );



Hi,

It’s hardcoded because I don’t want to use any inline JavaScript (something I’m trying out in my project), and different actions different dialog title. Thanks for pointing this out, maybe I will try to use title from a link for dialog title or something like that, I will have to think about it then I will be updating the extension.

Hi,

Is there any way to fetch instance in actionAdd controller like:


$upload1 = CUploadedFile::getInstancesByName('upload1');

I don’t know how fetch it from json “success” response.

Regards

Hi, I’ve seen that you published a new version, I just tried it but found the same issue with the date picker (now working) un the popup. Do you had the chance of working out this issue or it’s not done yet? Just to confirm =)

Hi, no I haven’t published a new version, just letting everyone know that it’s almost done. It should be published by the end of the month (I will sacrifice a few hours of my personal time in worst case scenario).

Then working on the new version, I jest JUI widgets and was very happy that they worked, hovewer a bit later it stopped working, after some testing I found that it was because one of widgets was trowing a JavaScript error (which wasn’t shown in firebug console), so I just started removing other widgets to pinpoint which one was at fault, and then I found it just went to fixing that widget. You might try this method out too, maybe it will help.

Regards

Thank you, I’ll wait for the new version, I’ve seen the last update set on oct 6 in the extension page and guessed that you posted a new version. I will still trying to figure out how to make it work, but I will also check the new version of eupdatedialog when it’s ready.

The update was because I added a little note to the extension letting everyone know that this extension is not dead I’m almost done with it. The biggest thing I’m running from is writing the documentation for it, as I’m the one who wrote this extension and even I’m not sure how it works :D But I will try to glue all the pieces together and finally publish it so I could start thinking about the next update (I’m still not happy about it, and think it can be better), so just wait a little bit longer :)

Hello, I’m new in Yii, I followed the instructions for using the extension and I could not run, nor the basic usage.

Copy the files in place

Assuming a model ‘Customer’

  1. I see my model in ‘protected/controllers/CustomerController.php’ the method LoadModule(), Ok



	public function loadModel()

	{

		if($this->_model===null)

		{

			if(isset($_GET['id']))

				$this->_model=Customer::model()->findbyPk($_GET['id']);

			if($this->_model===null)

				throw new CHttpException(404,'The requested page does not exist.');

		}

		return $this->_model;

	}



  1. At the end of my controller ‘protected/controllers/CustomerController.php’ put the method setFlash()



	public function setFlash( $key, $value, $defaultValue = null )

	{

	  Yii::app()->user->setFlash( $key, $value, $defaultValue );

	}



  1. Change actions(), also in ‘protected/controllers/CustomerController.php’? put at the end? or in ‘protected/components/controller.php’?, or in ‘protected/controllers/SiteController.php’ if it is here, what do I do with the code that is already here?

  2. I make changes in my view and add a update-dialog-open-link class to all the links or




<?php

echo CHtml::link( 'Create', array( 'create' ),

  array(

    'class' => 'update-dialog-open-link',

    'data-update-dialog-title' => Yii::t( 'app', 'Create a new mix' ),

));

?>



  1. I add the widget in my view, is in ‘protected/views/Customer/create.php’? or directly on the form ‘protected/views/Customer/_form.php’?



<div class="form">


<?php 

$this->widget( 'ext.EUpdateDialog.EUpdateDialog' );


$form=$this->beginWidget('CActiveForm', array(

	'id'=>'project-form',

	'enableAjaxValidation'=>false,

)); ?>

...



Either way is not working.

Will you show me step by step detail how to run this extension?

Sorry for my google-English.

Regards.

With a quick look as far I can tell:

  1. Correct

  2. Correct

  3. Add it to your customercontroller.php (you are just adding external actions to your controller)

  4. just add the class to the links you want to work with eupdatedialog (example: you want edit link to work through eupdatedialog so you add your class, but you want your delete link to work through normal redirects so you won’t add the class to this link)

  5. add it to the view from which you want to access actions using eupdatedialog (example: you want to create/edit/etc from admin view then add the widget to admin view; if you have a select in your form and you want to add additional options to that select using a link, then add it in your _form or create view)

Thank you very much for responding.

1) Function loadModule() in protected/controllers/ProjectController.php




	public function loadModel()

	{

		if($this->_model===null)

		{

			if(isset($_GET['id']))

				$this->_model=Project::model()->findbyPk($_GET['id']);

			if($this->_model===null)

				throw new CHttpException(404,'The requested page does not exist.');

		}

		return $this->_model;

	}



2) Function setFlash() at the end of protected/controllers/ProjectController.php




	public function setFlash( $key, $value, $defaultValue = null )

	{

	  Yii::app()->user->setFlash( $key, $value, $defaultValue );

	}



3) Function actions() at the end of protected/controllers/ProjectController.php




	public function actions()

	{

	  return array(

	    'view' => 'application.actions.CreateAction',

	  );

	}



4) and 5) With this code in protected/views/project/index.php:




<?php

$this->breadcrumbs=array(

	'Projects',

);


$this->menu=array(

	array('label'=>'Create Project', 'url'=>array('create')),

	array('label'=>'Manage Project', 'url'=>array('admin')),

);


$this->widget( 'ext.EUpdateDialog.EUpdateDialog' );


?>


<h1><?php echo Yii::t('app', 'Projects'); ?></h1>


<?php

echo CHtml::link( 'Create', array( 'create' ),

  array(

    'class' => 'update-dialog-open-link',

    'data-update-dialog-title' => Yii::t( 'app', 'Create a new mix' ),

));

?>


<?php $this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_view',

)); ?>



Just get this dialog (image attached):

What is missing me?

Regards.

Similar issue here. The first time I click the CREATE MIX link I get this error:

b is null

inside jquery.cookie.js (line 10)

jQuery.cookie=function(b,j,m){if(typeo…tring(b.length+1));break}}}return d}};

then I click the link again and the dialog opens, the "loading…" text dissapears, but the dialog stays empty.

Any clue?

I found the solution for both issues. The dialog was empty because in my case I was using the old JSON attribute (div, instead of content, which is the name in the new version).

The jqueryCookie seems to be a bug… check the line 153 of EUpdateDialog.js, looks like:

if(  ( jQuery.cookie ) &amp;&amp; ( typeof this.csrfTokenName &#33;= null )  )

and should be:

if( ( typeof this.csrfTokenName &#33;= null ) &amp;&amp; ( this.csrfTokenName &#33;= null ) &amp;&amp; ( jQuery.cookie ) )

because if the token name is empty the IF condition evaluates to TRUE. I dont understand why it check for the TYPEOF instead of the property itself… there is a reason or it’s just a typo/bug?

This does not solve my problem, I still see only the window of dialogue with the text ‘Loading …’.

What am I missing?

Remember to adjust the actionCreate() in your controller to return the create form through AJAX, something like this:

(Mi model is called ‘Provincia’, use the correct name for your model)

        if(isset(&#036;_POST['Provincia']))


        {


            &#036;model-&gt;attributes=&#036;_POST['Provincia'];


		if (&#036;model-&gt;save()) 


		{


                if (Yii::app()-&gt;request-&gt;isAjaxRequest)


                {


                    echo CJSON::encode(array(


                        'status'=&gt;'success', 


                        'div'=&gt;&quot;&lt;div id='saveconfirm'&gt;Los datos han sido almacenados.&lt;/div&gt;&quot;,


			'option'=&gt;CHtml::tag('option',array (


                                'value'=&gt;&#036;model-&gt;id,


                                'selected'=&gt;true


                            ),CHtml::encode(&#036;model-&gt;cod_prov),true)





                        ));


                    exit;               


                }


                else


                    &#036;this-&gt;redirect(array('view','id'=&gt;&#036;model-&gt;id));


            }


        }

Thank you very much for your time and patience.

This is the code:




public function actionCreate()

{

	$model=new Project;


	if(isset($_POST['Project']))

	{

		$model->attributes=$_POST['Project'];

		if($model->save())

		{

			if (Yii::app()->request->isAjaxRequest)

			{

				echo CJSON::encode(array(

					'status'=>'success',

					'div'=>"<div id='saveconfirm'>Los datos han sido almacenados.</div>",

					'option'=>CHtml::tag('option',array (

							'value'=>$model->id,

							'selected'=>true), CHtml::encode($model->id),true)

					));

				exit;

			}

			else 

				$this->redirect(array('view','id'=>$model->id));

		}				

	}

	if (Yii::app()->request->isAjaxRequest)

        {

            echo CJSON::encode(array(

                'status'=>'failure', 

                'div'=>$this->renderPartial('_form', array('model'=>$model), true)

            ));

            exit;               

        }

        else

	    $this->render('create',array(

		'model'=>$model,

	    ));

}



Still do not see anything in the window, the text ‘Loading …’ no longer seen.

Replace ‘div’ with ‘content’

version 2 of EUpdateDialog uses ‘content’ as the JSON identifier.

It works perfect, thank you very much, excellent work.

Another question, I have a datepicker in _form.php no longer see.

Is there a way to make it look in the dialogs?




<div class="row">

	<?php echo $form->labelEx($model,'create_time'); ?>

	<?php 

		// echo $form->textField($model,'create_time'); 

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

			 array(

				 'model'=>'$model',

				 'name'=>'Project[create_time]',

				 'value'=>$model->create_time,

				 'htmlOptions'=>array('size'=>10, 'style'=>'width:120px !important'),

					 'options'=>array(

		 				 'dateFormat'=>Yii::t('app', 'm/d/y'),

						 'showButtonPanel'=>true,

						 'changeMonth'=>true,                                      

						 'changeYear'=>true,

		 				 'closeText'=>'Done',

		 				 'currentText'=>'Today',

						 ),

					 )

				 );

	?>

	<?php echo $form->error($model,'create_time'); ?>

</div>



Find a solution? or still waiting. =(

Great to hear that it worked for you! =) I had the same issue with the datepicker and EUpdateDialog, I think that it can be solved using Version 2 of EUpdateDialog and playing with the JS initialization options, but didn’t tried it yet, maybe andrew2mar can tell us how to manage it.

Thanks, then wait.

We read. :rolleyes:

I’m not sure my self why I was checking for typeof, probably had a very big idea in my head for something :D

Made some changes to the check, but for some reason to me it was working either way :D