[eluser]steward[/eluser]
Hey this is very cool.
Only I don't want my table prefix in the controller names and so forth.
So I changed your list of links for each table into a form, with a checkbox for each table name, and some extra fields for what I want to name my stuff.
Code:
function_select()
{
...
$this->load->helper('form');
$rows='';
foreach ($tables as $table)
{
$rows .= form_checkbox(
array(
'name' => 'NAMETABLE',
'value' => $table,
'checked' => FALSE,
'style' => ''
) );
$rows .= " $table<BR />\n";
}
$form='';
$form .= form_open('generate/ProcessTable/process');
$form .= $rows;
$form .= form_input('gen[NAMEMODEL]', 'MyModel');
$form .= "<BR />\n";
$form .= form_input('gen[NAMEVIEW]', 'MyView');
$form .= "<BR />\n";
$form .= form_input('gen[NAMECONTROLLER]', 'MyController');
$form .= "<BR />\n";
$form .= form_submit('submit','gen');
$form .= form_close();
echo $form;
}
function ProcessTable ( $table_name )
{
$table_name = $this->input->get_post('NAMETABLE');
$gen = $this->input->get_post('gen');
$name_controller = ucfirst( strtolower( $gen['NAMECONTROLLER'] ) );
$name_view = ucfirst( strtolower( $gen['NAMEVIEW'] ) );
$name_model = ucfirst( strtolower( $gen['NAMEMODEL'] ) );
$name_model_lower = strtolower( $name_model );
echo '<PRE>';
print_r($gen);
echo '</PRE>';
echo "<BR>table_name=$table_name";
echo "<BR>name_controller=$name_controller";
echo "<BR>name_model=$name_model";
echo "<BR>name_view=$name_view";
die('<P>end');
... you have doubled up "$table_name" to also be the controller name etc.
In the next release, if you set those variables at the top of the ProcessTable() function, and separate out the subsitutions for table_name from NAMECONTROLLER etc, then we can modify it to suit our needs faster. As it is, we sorta gotta hunt through your code.
Also needs some documentation, maybe just a little more blurb on the welcome page.
Ie:
Look in the /templates folder to see create your own output.
The following substitutions are made during generation:
%FIELDS_ID%
%FIELDS_STRING%
%MODEL_CALL%
%NAME_CONTROLLER%
%NAME_MODEL%
%NAME_MODEL_LOWER%
%NAME_VIEW_FORM%
%SET_RULES%
%SET_VALUE%
%TABLE_NAME%
%VALIDATION_FALSE%
%VALIDATION_TRUE%
%VALUES_INIT%
%VALUES_INIT_EDIT%
It's a great idea and a good start. Thanks!