Skip to content

Instantly share code, notes, and snippets.

@schmunk42
Last active December 23, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schmunk42/6641457 to your computer and use it in GitHub Desktop.
Save schmunk42/6641457 to your computer and use it in GitHub Desktop.
Sample provider function for rendering custom inputs with gtc
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