Page creation doesn't work with form method post

Hey,

So I have a profile page which is generated via a route. On the profile page, users can create posts that will be displayed there.

In my controller, I have something like this:

<?php

    return function($site, $page, $pages) {
            
        if(r::is('post') and get('submit')) {
            $newPage = page('postari/user')->children()->create('pageName', 'postare', array(
                    'title' => $site->user()->username() . 'Post 2',
                    'text' => get('text'),
                    'date' => date('d-m-Y H:i:s')
                  ));
        }
    };
            
?>

I’ve simplified the code for the post’s sake. Either way, after submitting my form I get back on the profile page, but it gives me a 404 instead of displaying back the profile.

Is there a problem with being a generated page?

I don’t quite understand where the error occurs? On the newly generated page or on the profile page? Have you checked if the page get’s created in the filesystem? It does not matter how the page is created.

Sorry, I’m so frustrated after countless tries I can’t even formulate this right.

So on my route generated profile for a user (localhost/profile/user), I list all the posts by that user via a snippet. On the same page, above the listed posts, I have a form with a textarea and a submit button.

When you type something in the textarea and submit it, a child page of posts/user should be created. Unfortunately, the page doesn’t get created (not even in the file system), and while it still keeps me on the same link for the user profile page, it gives me a 404.

I thought it might be a problem because the profile page doesn’t actually exist since it’s generated via calling a template through a route.

Hope this makes more sense.

UPDATE: It seems like no matter what’s in the controller for the form bit, it still returns a 404 on submit.
For example when submitting the form, even with this, I still get a 404:

<?php

    return function($site, $page, $pages) {
        $say = false;
        
        if(r::is('post') and get('submit')) {
            $say = true;
        }
        
        return array('say' => $say);
    };

?>

Any ideas?

Why not putting the “create if not found” with a bunch of “security” checks on the error page controller?
Create the page and “go(‘there’)”…?

The problem is the controller doesn’t do anything if the form method is set to post.

It wouldn’t be a problem if I used get instead. It works liek a charm for the text field, but I’m also having uploads, so that doesn’t work with get.

Any ideas?