simple dialog box feature for Yii

hello everyone, i build a dialog box feature that may be usefull for everyone using yii framework.

Only one component is requiered: DialogBox.php and no more.

The dialogbox opens a jquery-based popup with an action inside. No specific codding for dialog box needed.

hope it will be usefull…

[b]

[/b]

a screen shot, showing you how it looks like, the ‘zipcode’ labeled input element receive the dialog output when it is finished. the dialog runs an action as content body, when user press ‘Finish’ buttton then the dialog box is automatically closed and its return value is passed into the zipcode input box.

[b]

[/b]

[b]please note that the entire dialog content (including control buttons) is a standard Yii action (running inside a iframe), not special codding needed for dialog. if your actions runs directly from your navigator then it runs too into the dialog box.

[/b]

sample view:


<div id='dialogBoxLaunchIconPosition' style="margin-top: 10px;">

To start testing this dialog box sample, click this icon:

<?php DialogBox::createDialogBox(

    $this

   ,"myDialog1"

   ,"Type your name:"

   ,"site/sample"

   ,"testinput"

   ,"sampleIconCssStyle"

   ,320,300

 ); 

?>




When dialog is finished then your input is shown here:<br/>

<input id='testinput'></input>


 </div>

the code for the action response to return the dialog value is as follows:





	public function actionSample()

	{

    	$model=new SampleModel;

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

    	{

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

        	if($model->validate())

        	{

            	// form inputs are valid, do something here

            	DialogBox::closeDialogBox($model->name,"index.php?r=site/sample");

            	return;

        	}

    	}

    	$this->layout = "dialoglayout";

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

	}	



[b][u]

[/u][/b]