laravel 4修改控制器内的输入值[重复]

This question already has an answer here:

Okay, this one is a bit tricky and unusual, but I need to do it for one of my project.

so I have 2 routes :

Route::get('table/edit',  array('uses'=>'CompanyController@editTable'));

Route::post('table/update',  array('uses'=>'CompanyController@editTableAction'));

Now the fields in the database table I'll be storing data are dynamic, So I must take advantage of the :

Input::all(); 

Method. There's a hidden input in my form

<input type="text" name="database_field_name_user_friendly" value="User Input Some Name" />

<input type="hidden" name="database_field_name" value="" />

Now, as you can see,

Input::get('database_field_name');

is empty. Is there a way I can set the value of this input box inside the controller? I need to process the value from another input field database_field_name_user_friendly . I'll run regex to make it a valid MySQL field name.

Any help will be much appreciated.

</div>

I got the solution just after posting the question :p

Hope this helps someone else! Really very easy. Inside your controller

Let's process the input

$database_table_name = strtolower(Input::get('account_database_table_name'));
//make alphaunermic
$database_table_name = preg_replace("/[^a-z0-9_\s-]/", "", $database_table_name);
//Clean multiple dashes or whitespaces
$database_table_name = preg_replace("/[\s-]+/", " ", $database_table_name);
//Convert whitespaces and underscore to dash
$database_table_name = preg_replace("/[\s_]/", "_", $database_table_name);

And then simply set the value! Using Laravel Input::merge method

 Input::merge(array('account_database_table_name'=>$database_table_name));

Thanks!