Last active
December 23, 2015 13:19
-
-
Save schmunk42/6641457 to your computer and use it in GitHub Desktop.
Sample provider function for rendering custom inputs with gtc
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
public function generateActiveField($model, $column) | |
{ | |
if ($column->autoIncrement) { | |
return false; | |
} | |
switch ($column->name) { | |
case 'created_at': | |
case 'updated_at': | |
return "echo \$form->textField(\$model,'{$column->name}',array('disabled'=>'disabled'))"; | |
break; | |
case 'rgb': | |
return "\$this->widget('TbColorPicker', array('model'=>\$model,'attribute'=>'{$column->name}'))"; | |
break; | |
case 'default_p3media_id': | |
case 'p3media_id': | |
case 'icon_url': | |
return "\$this->widget('P3MediaSelect', array('model'=>\$model,'attribute'=>'{$column->name}'))"; | |
break; | |
} | |
// Render a dropdown list if the model has a method optsColumn(). | |
$func = "opts" . str_replace("_", "", $column->name); | |
if (method_exists($model, $func)) { | |
return "echo \$form->dropDownList(\$model,'{$column->name}',{$model}::{$func}(),array('empty'=>'undefined'));"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment