A Simple Dialog Box

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 class opens a jquery-based popup containing an action inside. No specific codding for dialog box needed, the usage is very simple.

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, [color="#0000ff"]when user press ‘Finish’ buttton then the dialog box is automatically closed and its return value is passed into the zipcode input box[/color].

[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.[color="#0000ff"] if your actions runs directly from your navigator then it runs too into the dialog box[/color].

[/b]

TO LAUNCH THE DIALOG BOX,

this piece of code must be used to open the popup, the createDialogBox call creates a css-styled icon ready and configured to launch the jquery dialogbox.


<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 will be shown in this Input element:<br/>

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


</div>

CLOSING AND RETURN, 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));

	}    



This was very useful, … great work, thank you for sharing, Ad

How to save from this form???