Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserForm fields from Userform block appear in PageContent block after form submission #62

Open
AlphaCactus opened this issue May 17, 2022 · 3 comments

Comments

@AlphaCactus
Copy link

  1. Create a Page and add some content to the Content field.
  2. Add a PageContent Block
  3. Add a Userform Block (configure with some minimum required fields)
  4. Publish the Page.
  5. View the page on the front end. (looks ok)
  6. Fill and Submit the form.

Result:

  1. PageContent does not appear. (whether it should or not may depend on specific usage, so not sure what correct behavior is)
  2. The unfilled form appears in the PageContent block. (incorrect behavior)
  3. The "show on completion" message appears in the Userform block. (correct behavior)

Workaround:
Do not use Page Content block and Userform block on the same page.

@asecondwill
Copy link

+1 on this. You can't really do that workaround if you have a site full of content in the $content field.

I'm trying to workaround by adding to page.php

function ContentActual(){
            return $this->Content;
        }

and using

ContentActual.RAW

in most templates/layouts and then

$Content

in SilverStripe/UserForms/Model/Layout/UserDefinedForm.ss

Which seems to work ok.

@asecondwill
Copy link

The above needs work, because it does not include changing things like silverstripe links into actual links

@asecondwill
Copy link

so based on
https://docs.silverstripe.org/en/4/developer_guides/templates/casting/

im now just doing

$contentActual

in template

and then in pageController

   private static $casting = [
        'ContentActual' => 'HTMLText' 
    ];

    public function ContentActual(){
        return $this->Content;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants