I am trying to bootstrap simple REST app using latest Symfony (2.4.5) with FOSRestBundle (dev-master 6b384c1).
My configuration:
fos_rest:
format_listener: true
view:
view_response_listener: true
sensio_framework_extra:
view: { annotations: false }
router: { annotations: true }
My routing:
products:
type: rest
resource: Telemetrik\Bundle\ProductBundle\Controller\ProductsController
Controller:
<?php
// namespace & imports
class ProductsController extends Controller
{
/**
* @return Form
* @View("TelemetrikProductBundle::form.html.twig")
*/
public function newProductAction()
{
return $this->getForm();
}
/**
* @param Request $request
* @return View|Form
* @View
*/
public function postProductsAction(Request $request)
{
$form = $this->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
// Logic placeholder
}
return $form;
}
protected function getForm()
{
return $this->createForm(new ProductType());
}
}
When using router:debug
I get:
new_product GET ANY ANY /products/new.{_format}
post_products POST ANY ANY /products.{_format}
Which is mostly fine BUT since newProductAction
is supposed to be a form:
- I don't want it to be accessible from formats other than HTML
- I want to access my form from
/products/new
not/products/new.html
(which right seems to be the only option I can access that resource). If I go toproducts/new
I get:Format '' not supported, handler must be implemented