-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tabular input widget and examples
- Loading branch information
Showing
4 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="simple"> | ||
<?php echo CHtml::activeLabelEx($model,"firstname"); ?> | ||
<?php echo CHtml::activeTextField($model,"[$index]firstname"); ?> | ||
<?php echo CHtml::error($model,"[$index]firstname"); ?> | ||
</div> | ||
|
||
<div class="simple"> | ||
<?php echo CHtml::activeLabelEx($model,"lastname"); ?> | ||
<?php echo CHtml::activeTextField($model,"[$index]lastname"); ?> | ||
<?php echo CHtml::error($model,"[$index]lastname"); ?> | ||
</div> | ||
|
||
<div class="simple"> | ||
<?php echo CHtml::activeLabelEx($model,"eyecolor_code"); ?> | ||
<?php echo CHtml::activeDropDownList($model,"[$index]eyecolor_code", Lookup::items('eyecolor')); ?> | ||
<?php echo CHtml::error($model,"[$index]eyecolor_code"); ?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<td> | ||
<?php echo CHtml::activeTextField($model,"[$index]firstname"); ?> | ||
<?php echo CHtml::error($model,"[$index]firstname"); ?> | ||
</td> | ||
<td> | ||
<?php $this->widget('ext.widgets.autocomplete.XJuiAutoComplete', array( | ||
'model'=>$model, | ||
'attribute'=>"[$index]lastname", | ||
'source'=>$this->createUrl('request/suggestLastname'), | ||
|
||
)); ?> | ||
<?php echo CHtml::error($model,"[$index]lastname"); ?> | ||
</td> | ||
<td> | ||
<?php echo CHtml::activeDropDownList($model,"[$index]eyecolor_code", Lookup::items('eyecolor')); ?> | ||
<?php echo CHtml::error($model,"[$index]eyecolor_code"); ?> | ||
</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
$this->pageTitle=Yii::app()->name . ' - ' . Yii::t('ui', 'Tabular Inputs'); | ||
$this->layout='leftbar'; | ||
$this->leftPortlets['application.portlets.ExtensionMenu']=array(); | ||
|
||
// set demo value | ||
$persons=array( | ||
Person::model()->findbyPk(1), | ||
Person::model()->findbyPk(2) | ||
); | ||
$persons2=array( | ||
Person2::model()->findbyPk(1), | ||
Person2::model()->findbyPk(2), | ||
Person2::model()->findbyPk(3), | ||
Person2::model()->findbyPk(4) | ||
); | ||
?> | ||
|
||
<h2><?php echo Yii::t('ui','Tabular Inputs'); ?></h2> | ||
|
||
<h3>Basic Example</h3> | ||
<p>minimal configuration, no style</p> | ||
|
||
<div class="form"> | ||
<?php $this->widget('ext.widgets.tabularinput.XTabularInput',array( | ||
'models'=>$persons, | ||
'inputView'=>'extensions/_tabularInput', | ||
'inputUrl'=>$this->createUrl('request/addTabularInputs'), | ||
'removeTemplate'=>'<div class="action">{link}</div>', | ||
'addTemplate'=>'<div class="action">{link}</div>', | ||
)); ?> | ||
</div> | ||
|
||
<div class="tpanel"> | ||
<div class="toggle"><?php echo Yii::t('ui','View code'); ?></div> | ||
<?php $this->beginWidget('CTextHighlighter',array('language'=>'PHP')); ?> | ||
$this->widget('ext.widgets.tabularinput.XTabularInput',array( | ||
'models'=>$persons, | ||
'inputView'=>'extensions/_tabularInput', | ||
'inputUrl'=>$this->createUrl('request/addTabularInputs'), | ||
'removeTemplate'=>'<div class="action">{link}</div>', | ||
'addTemplate'=>'<div class="action">{link}</div>', | ||
)); | ||
<?php $this->endWidget(); ?> | ||
</div> | ||
|
||
<div class="tpanel"> | ||
<div class="toggle"><?php echo Yii::t('ui','Browse code'); ?></div> | ||
<pre> | ||
/protected/extensions/widgets/tabularinput/XTabularInput.php | ||
/protected/views/site/extensions/_tabularInput.php | ||
/protected/controllers/RequestController.php | ||
/protected/extensions/actions/XTabularInputAction.php | ||
</pre></div> | ||
|
||
<br /> | ||
|
||
<h3>Advanced Example</h3> | ||
<p>tabular inputs configured into table layout, buttons styled, autocomplete widget used in dynamic rows</p> | ||
|
||
<div class="form"> | ||
<?php $this->widget('ext.widgets.tabularinput.XTabularInput',array( | ||
'models'=>$persons2, | ||
'containerTagName'=>'table', | ||
'headerTagName'=>'thead', | ||
'header'=>' | ||
<tr> | ||
<td>'.CHtml::activeLabelEX(Person::model(),'firstname').'</td> | ||
<td>'.CHtml::activeLabelEX(Person::model(),'lastname').'</td> | ||
<td>'.CHtml::activeLabelEX(Person::model(),'eyecolor_code').'</td> | ||
<td></td> | ||
</tr> | ||
', | ||
'inputContainerTagName'=>'tbody', | ||
'inputTagName'=>'tr', | ||
'inputView'=>'extensions/_tabularInputAsTable', | ||
'inputUrl'=>$this->createUrl('request/addTabularInputsAsTable'), | ||
'addTemplate'=>'<tbody><tr><td colspan="3">{link}</td></tr></tbody>', | ||
'addLabel'=>Yii::t('ui','Add new row'), | ||
'addHtmlOptions'=>array('class'=>'blue pill full-width'), | ||
'removeTemplate'=>'<td>{link}</td>', | ||
'removeLabel'=>Yii::t('ui','Delete'), | ||
'removeHtmlOptions'=>array('class'=>'red pill'), | ||
)); ?> | ||
</div> | ||
|
||
<div class="tpanel"> | ||
<div class="toggle"><?php echo Yii::t('ui','View code'); ?></div> | ||
<?php $this->beginWidget('CTextHighlighter',array('language'=>'PHP')); ?> | ||
$this->widget('ext.widgets.tabularinput.XTabularInput',array( | ||
'models'=>$persons2, | ||
'containerTagName'=>'table', | ||
'headerTagName'=>'thead', | ||
'header'=>' | ||
<tr> | ||
<td>'.CHtml::activeLabelEX(Person::model(),'firstname').'</td> | ||
<td>'.CHtml::activeLabelEX(Person::model(),'lastname').'</td> | ||
<td>'.CHtml::activeLabelEX(Person::model(),'eyecolor_code').'</td> | ||
<td></td> | ||
</tr> | ||
', | ||
'inputContainerTagName'=>'tbody', | ||
'inputTagName'=>'tr', | ||
'inputView'=>'extensions/_tabularInputAsTable', | ||
'inputUrl'=>$this->createUrl('request/addTabularInputsAsTable'), | ||
'addTemplate'=>'<tbody><tr><td colspan="3">{link}</td></tr></tbody>', | ||
'addLabel'=>Yii::t('ui','Add new row'), | ||
'addHtmlOptions'=>array('class'=>'blue pill full-width'), | ||
'removeTemplate'=>'<td>{link}</td>', | ||
'removeLabel'=>Yii::t('ui','Delete'), | ||
'removeHtmlOptions'=>array('class'=>'red pill'), | ||
)); | ||
<?php $this->endWidget(); ?> | ||
</div> | ||
|
||
<div class="tpanel"> | ||
<div class="toggle"><?php echo Yii::t('ui','Browse code'); ?></div> | ||
<pre> | ||
/protected/extensions/widgets/tabularinput/XTabularInput.php | ||
/protected/views/site/extensions/_tabularInputAsTable.php | ||
/protected/controllers/RequestController.php | ||
/protected/extensions/actions/XTabularInputAction.php | ||
</pre></div> | ||
|
||
<br /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* To apply classic skin, assign skin attribute: | ||
* $this->widget('XJuiAutocomplete', array('skin'=>'notDefault')); | ||
*/ | ||
return array( | ||
'default'=>array( | ||
'options'=>array( | ||
'delay'=>300, | ||
'minLength'=>2, | ||
'open'=>'js: function( event, ui ) { | ||
$( this ).autocomplete( "widget" ) | ||
.find( "ui-menu-item-alternate" ) | ||
.removeClass( "ui-menu-item-alternate" ) | ||
.end() | ||
.find( "li.ui-menu-item:odd a" ) | ||
.addClass( "ui-menu-item-alternate" ); | ||
}', | ||
), | ||
'htmlOptions'=>array( | ||
'style'=>'background: #ffffe0;' | ||
), | ||
), | ||
); |