Page 1 of 1
EXTENDING CRUD GENERATION (scaffolding)
#1
Posted 03 January 2010 - 08:04 PM
HI,
I am return after same pause!
Anyone has extended the Yii Crud default system for same aditional features?
Like search, limit browsing fields (under admin manage),lookup between two or more tables from FK fiels...
if have not, Anyone can work with me to develop this feature for YII?
Regards!!!
I am return after same pause!
Anyone has extended the Yii Crud default system for same aditional features?
Like search, limit browsing fields (under admin manage),lookup between two or more tables from FK fiels...
if have not, Anyone can work with me to develop this feature for YII?
Regards!!!
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
#2
Posted 04 January 2010 - 03:00 AM
I have done a little dirty thing like this, without FK fields, for Yii 1.0:
and in the controller:
in the view, the main part is _form.php, needs also to be enhanced
Maybe Yii 1.1 with CActiveDataProvider or http://www.yiiframew...aydataprovider/ can do this more easily.
class TableData extends CActiveRecord {
private static $tableName;
public function __construct($attributes=array(), $scenario='') {
if (self::$tableName === null) {
throw new CDbException(Yii::t('main', '"TableData" requires a "tableName" property.'));
}
parent::__construct($attributes, $scenario);
}
public static function model($className=__CLASS__) {
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName() {
return self::$tableName;
}
public static function setTableName($tableName) {
if (! in_array($tableName, self::$db->schema->tableNames)) {
throw new CDbException(Yii::t('main', 'Table "{table}" does not exist.', array('{table}'=>$tableName)));
}
self::$tableName = $tableName;
}
/**
* @return array validation rules for model attributes.
*/
public function rules() {
$rules = array();
$required = array();
foreach (self::$db->schema->getTable($this->tableName())->columns as $col) {
if (!$col->allowNull) {
$required[] = $col->name;
}
}
if (count($required) > 0) {
$rules[] = array(join(', ', $required), 'required');
}
return $rules;
}
/*
* @todo relations()
*/
}
and in the controller:
/**
* Defines table on which work
*/
private function setTable() {
$table = _request('table');
if ($table) {
TableData::setTableName($table);
return $table;
}
return null;
}
in the view, the main part is _form.php, needs also to be enhanced
<?php foreach ($columns as $column=>$props):
if ($props['dbType'] == 'geometry') {
continue;
}
?>
<div class="simple">
<?php echo CHtml::activeLabelEx($model, $column); ?>
<?php echo CHtml::activeTextField($model, $column); ?>
</div>
<?php endforeach;?>
Maybe Yii 1.1 with CActiveDataProvider or http://www.yiiframew...aydataprovider/ can do this more easily.
#3
Posted 04 January 2010 - 06:02 AM
realy Thanks, Analizing testing... AND working in the search feature
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
#4
Posted 04 January 2010 - 07:39 AM
working with the command line tool CRUD, renamed to crud2
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
#5
Posted 04 January 2010 - 05:42 PM
initial code:
this code loockup all tables on the DB that have a relationship with the fields of specific table, that automatically generate the array relational rules.
for
result:
this code loockup all tables on the DB that have a relationship with the fields of specific table, that automatically generate the array relational rules.
for
public function relations()
{
return array();
}
<?
/* coded by Max Rivera */
$con=mysql_connect('localhost','cpga_sis','******');
$db=mysql_select_db('cpga_sis',$con);
function ltable()
{
global $db;
$sql = mysql_query("SHOW TABLE STATUS");
while($linha = mysql_fetch_assoc($sql)):
$r[pkey($linha[Name])]=$linha[Name];
$q[$linha[Name]]=pkey($linha[Name]);
endwhile;
$x[0]=$r;
$x[1]=$q;
return $x;
}
function pkey($tabela)
{
global $db;
$query="DESC {$tabela}";
$results=mysql_query($query);
while ($row=mysql_fetch_array($results))
{
if ($row[Key]=="PRI")
{
return $row[Field];
}
}
return false;
}
function fk($tabela)
{
$chaves=ltable();
$pkey=pkey($tabela);
$query="DESC {$tabela}";
$results=mysql_query($query);
while ($row=mysql_fetch_array($results))
{
if(in_array($row[Field],$chaves[1]) AND $row[Field]!=$pkey)
{
$s=$chaves[0][$row[Field]];
$arr[$s]=$row[Field];
}
}
$r ="array(";
foreach($arr as $tabela=>$pk)
{
$r .= "'".$tabela."'=>array(self::BELONGS_TO, '".$tabela."','".$pk."'),";
}
$r .=")";
return $r;
}
$tabela='usuario';
print_r(fk($tabela));
?>
result:
array( 'lab'=>array(self::BELONGS_TO, 'lab','lab_id'),
'grupo'=>array(self::BELONGS_TO, 'grupo','grupo_id'),
)
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
#6
Posted 06 January 2010 - 04:57 AM
I have translated the (few) Strings used in the default crud Generator to german a while ago.
I think it makes sense to provide a set of default crud pages per language, rather than making
the crud generator i18n-capable, consider this:
crud model style=default lang=de js=active
or
crud model style=futuristic lang=gb js=inactive
to get the crud command some more abilities.
In addition to this it would be cool if the yii-crud would get more intelligent deploying database rows, for example an boolean or tinyint(1) field should be generated as a checkbox; foreign key relations should get be generated as an combobox, date and timestamp to a datepicker (when js is enabled), and so on...
Maybe we build something like this for yii 1.2
I think it makes sense to provide a set of default crud pages per language, rather than making
the crud generator i18n-capable, consider this:
crud model style=default lang=de js=active
or
crud model style=futuristic lang=gb js=inactive
to get the crud command some more abilities.
In addition to this it would be cool if the yii-crud would get more intelligent deploying database rows, for example an boolean or tinyint(1) field should be generated as a checkbox; foreign key relations should get be generated as an combobox, date and timestamp to a datepicker (when js is enabled), and so on...
Maybe we build something like this for yii 1.2
#7
Posted 06 January 2010 - 08:36 AM
I have builded all you are saying (90%) but for yii 1.0
now I am rewrinting all for yii 1.x but I have some dificult becouse the developers has changed the parsing method for generate crud (templates and php code)...
now I am rewrinting all for yii 1.x but I have some dificult becouse the developers has changed the parsing method for generate crud (templates and php code)...
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
#8
Posted 06 January 2010 - 08:05 PM
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
#9
Posted 07 January 2010 - 12:13 PM
yii crud tool should generate different input field types depending on the field - not just text fields.
#10
Posted 08 January 2010 - 08:03 AM
GSTAR, on 07 January 2010 - 12:13 PM, said:
yii crud tool should generate different input field types depending on the field - not just text fields.
yii crud not generate relations on non fk fields
yii crud not generate loockup for dropdown list from another table
the views list manage in admin group_id is show 3, as better is group:Admin
date fields not have pickup date, enum fields is ignored, bolean ignored, etc....
YII crud is a baby.... simpony is "the man scaffolding", that we need all together work to modify the actual crud method for yii...
trying build code for Generate complete CRUD source code with YII... any help?
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
post comments here:
EXTENDING CRUD GENERATION (scaffolding)
old tentative released (module generator):
http://www.yiiframew...sion/modulegen/
Share this topic:
Page 1 of 1

Help














