Currently trying to port over a Contrib module and learn the new Drupal 8 architecture.
A google search revealed a possible issue related to this.
The cause could be that there's an underscore in the file name which violates psr-0 naming standards. Looks like i had that before and have renamed it just now and still have that issue after clearing the cache.
What would likely be the cause of the following error?
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "\drupal\form_example\forms\formexampleformone". in Symfony\Component\DependencyInjection\Container->get() (line 304 of /home/chris/workspace/d8/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Container.php).
The error occurs when i visit /examples/form_example/tutorial/1
form_example.routing.yml
form_example:
path: 'examples/form_example'
defaults:
# _form: '\Drupal\form_example\Forms\FormExampleForm'
_content: '\Drupal\form_example\Controller\FormExampleController::description'
requirements:
_access: 'TRUE'
form_example_tutorial_1:
path: 'examples/form_example/tutorial/1'
defaults:
_form: '\Drupal\form_example\Forms\FormExampleForm'
requirements:
_access: 'TRUE'
form_example.module
<?php
function form_example_menu() {
// $items = array();
// $items['examples/form_example'] = array(
// 'title' => 'Form Example',
// 'route_name' => 'form_example',
// 'access callback' => TRUE,
// 'expanded' => TRUE,
// );
$items['examples/form_example/tutorial'] = array(
'title' => 'Form Tutorial',
// 'page callback' => 'drupal_get_form',
'route_name' => array('form_example_tutorial'),
'access callback' => TRUE,
'description' => 'A set of ten tutorials',
// 'file' => 'form_example_tutorial.inc',
// 'type' => MENU_NORMAL_ITEM,
);
$items['examples/form_example/tutorial/1'] = array(
'title' => '#1',
// 'page callback' => 'drupal_get_form',
'route_name' => array('form_example_tutorial_1'),
'access callback' => TRUE,
'description' => 'Tutorial 1: Simplest form',
// 'type' => MENU_DEFAULT_LOCAL_TASK,
// 'file' => 'form_example_tutorial.inc',
);
return $items;
}
/lib/Drupal/form_example/Forms/FormExampleForm.php
<?php
/**
* @file
* Contains \Drupal\form_example\Form\FormExampleForm
*/
namespace Drupal\form_example;
use Drupal\Core\Form\FormInterface;
class FormExampleForm extends FormBase {
// form...
}