[eluser]eljunior[/eluser]
oh, no! I already forgave you once, now I'll have to forgive you one more!
correcting my english is ok, but assuming I'm spanish... (soy brasileño, ¡hombre viejo!

pero no te preocupes, me gustaría mucho ser uruguayo... :-D y mi nombre es "Elias Junior", por eso "eljunior". ;-))
thanks for the corrections, it actually looks funnier when corrected...
well, since you seems to use CI seriously and I've got your attention, I'd like some
advice in the following (I know it's not the appropriate thread, but if this turns in
something good, we'll create a thread for it):
I wanted to be able to use a dropdown for the foreign keys in scaffolding,
so I created this method in system/scaffolding/Scaffolding :
Code:
function _prepare_field_data($field_data)
{
foreach($field_data as $i => $field){
$table=null;
if(ereg('_id$',$field->name)){ // matches table_id
$table=ereg_replace('_id$','',$field->name);
}
if(ereg('^id_',$field->name)){ // matches id_table
$table=ereg_replace('^id_','',$field->name);
}
if(! ($table && $this->CI->db->table_exists($table)) ){
continue; // isn't a reference, skip it
}
$options = array(); // sets up an array of options
$query=$this->CI->db->get($table);
foreach($query->result_array() as $row){
// this assumes that first field is id,
// followed by a field description
$options[ current($row) ] = next($row);
}
$field_data[$i]->options=$options;
// changes field type for testing in the view
$field_data[$i]->type='reference';
}
return $field_data;
}
and called it from methods
add:
Code:
'fields' => $this->_prepare_field_data($this->CI->db->field_data($this->current_table)),
and in method
edit:
Code:
'fields' => $this->_prepare_field_data($query->field_data()),
and finally added an
elsif in the views for showing the dropdown:
Code:
<?php elseif ($field->type == 'reference'): // cont. acoxambre EDSJ ?>
<td><? echo form_dropdown($field->name,$field->options); ?></td>
now, I want to know if this thing is a good practice, if there are problems in this approach
or if it makes sense to have something like this in CI and if CI is likely to have something like that, and if it can be good just for me, or if you could use something like this,
and probably more questions, depending on your answer... :-D
¡muchas gracias, muchacho!
y ¡feliz navidad! :-D