I have a form I'd like to use as a standalone page, which I'm defining in a module I've called "SREvent". I have created modules/srevent/src/Form/SREventListForm.php:

 * @file
 * Contains Drupal\srevent\Form\SREventListForm.
namespace Drupal\srevent\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\srevent\Entity\SREvent;
use Drupal\field_collection\Entity\FieldCollectionItem;
use Drupal\field_collection\Entity\FieldCollection;

class SREventListForm extends FormBase {    
    public function getFormId() {
        return 'srevent_list_form';

    //used in getEvents()
    public $inactive = [];
    public $active = [];

    //function to get all appropriate entities
    function getEvents() {

     * {@inheritdoc}
    public function buildForm(array $form, FormStateInterface $form_state) {


        //form builder logic

        return $form;

     * {@inheritdoc}
    public function validateForm(array &$form, FormStateInterface $form_state) {

     * {@inheritdoc}
    public function submitForm(array &$form, FormStateInterface $form_state) {

In routing.yml, the route is as follows:

  path: '/srevent/listform'
    _form: '\Drupal\srevent\Form\SREventListForm'
    _title: 'SREvent List'
    _access: 'TRUE'

There are other routing entries in this file as well, but none of those are giving me errors. I double checked for typos in the routing file as well as to make sure all indents are spaces and not tabs.

After flushing the cache repeatedly, /srevent/listform is still a 404.

This is how I set up all of my forms and have never seen this issue before, and every post I see on the topic tells me to set up exactly like this.

Is there something I'm missing? This is driving me crazy...

closed as off-topic by kiamlaluno Dec 4 '18 at 21:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Did you clear the cache? – Kevin Sep 29 '17 at 1:29
  • Yes, I stated in my post that I flushed the cache repeatedly. – saramm1 Sep 29 '17 at 1:30
  • May be you should try writing the method getEvents() method below the submitForm method. OR you can first try to render simple form instead of using getEvents() method. Just try to add a single textfield and return the form. What I mean is to get the form called on the page initially, then go for adding complex functionalities inside it. – Gaurav Rajdeo Sep 29 '17 at 2:17
  • 1
    I have occasionally found I've forgotten to enable my new custom module... – Darvanen Sep 29 '17 at 3:36
  • 2
    @Darvanen my module is enabled, because I was working with fields that I added to an entity it creates – saramm1 Sep 29 '17 at 13:03

Try these steps one by one.

Keep calm.

1) Check you are in the correct domain in your browser

  • Ugh, I hate when this happens, wrong domain, lol.

2) Check you're uploading or committing to the correct environment

  • Download the file from the server to see if it indeed changed and make sure you're in the correct environment.

3) Check that your form (SREventListForm.php) is indeed inside the /Form folder.

Simplify your process

4) Back up your current module. Delete all the other routes except for the one that you're trying to dbug.

5) Simplify your form's code. Put some basic code in there.

6) Change your routes path

  • I did all of these steps before posting the question. – saramm1 Oct 2 '17 at 14:34
  • @saramm1 hmm strange, feel free to add a zip of your code, so I can give it a spin. – No Sssweat Oct 2 '17 at 18:49

You don't need the first slash in your path:

path: '/srevent/listform'

Change for this:

path: 'srevent/listform'

Clear caches after that. That can be the problem. I recommend following the form examples from examples 8.x. It contains very useful examples of drupal code.

Ensure too your routing yml file is stored in the same level of your module and is called srevent.routing.yml


In your routing.yml file under requirements try writing _permission: 'access content' instead of _access: TRUE


May be you should try creating a new permission like _permission: 'perfom some action', then you can create a permissions.yml file and write below mention code

perform some action:
  title: 'Perform some action (you can give any meaningful title over here)'
  restrict access: true

Once again just clear the cache, also you can try opening it in a private window after getting cache cleared.

I hope this should work.

Not the answer you're looking for? Browse other questions tagged or ask your own question.