I have a form in Symfony2 where a user is submitting info for their credit card. The form renders perfectly fine intially, but on submission, I get the error "An exception occured in driver: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)".
My code for the controller action:
<?php
/**
* Class: PaymentController
*
* This controller is used to serve an iframe that contains a form for
* a person's credit card information.
*
* @see Controller
*/
class PaymentController extends Controller
{
/**
* indexAction
*
* Display a form for a user to enter their credit card information
*
* @param Request $request
*/
public function subscribeAction(Request $request)
{
$ccForm = new CreditCard();
$form = $this->createForm(new CreditCardType(), $ccForm);
//This function attempts to connect to DB on form submission
$form->handleRequest($request);
//Never gets here
if ($form->isValid()) {
}
//render view here (this part works fine)
}
}
My question is why does $form->handleRequest($request)
attempt to connect to the DB? From the stacktrace it looks like the Validator classes call the Doctrine ORM and it's trying to connect to a db there. I don't want it to do that and I simply want to keep the data in memory and make some API calls with it.
I have no metadata on my entity class that would suggest that Doctrine should try to save it to the db. Any ideas?
Edit:
If I delete the doctrine configuration from app/config/config.yml
like below then I can access my form object perfectly fine after $form-isValid()
# Doctrine Configuration
#doctrine:
# dbal:
# driver: "%database_driver%"
# host: "%database_host%"
# port: "%database_port%"
# dbname: "%database_name%"
# user: "%database_user%"
# password: "%database_password%"
# charset: UTF8
# # if using pdo_sqlite as your database driver:
# # 1. add the path in parameters.yml
# # e.g. database_path: "%kernel.root_dir%/data/data.db3"
# # 2. Uncomment database_path in parameters.yml.dist
# # 3. Uncomment next line:
# # path: "%database_path%"
#
# orm:
# auto_generate_proxy_classes: false
# auto_mapping: false