Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » Userform Module - Strange error

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 353 Views
  • Peavers
    Avatar
    Community Member
    8 Posts

    Userform Module - Strange error Link to this post

    Error:

    [User Error] Couldn't run query: SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."Created", "SiteTree_Live"."LastEdited", "SiteTree_Live"."UserDefinedForm_Live", "UserDefinedForm_Live"."SubmitButtonText", "UserDefinedForm_Live"."OnCompleteMessage", "UserDefinedForm_Live"."ShowClearButton", "UserDefinedForm_Live"."DisableSaveSubmissions", "UserDefinedForm_Live"."EnableLiveValidation", "UserDefinedForm_Live"."HideFieldLabels", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree_Live"."Sort" FROM "SiteTree_Live" LEFT JOIN "UserDefinedForm_Live" ON "UserDefinedForm_Live"."ID" = "SiteTree_Live"."ID" WHERE ("UserDefinedForm_Live"."ID" = 9) AND ("SiteTree_Live"."ClassName" IN ('UserDefinedForm')) ORDER BY "SiteTree_Live"."Sort" ASC LIMIT 1 Unknown column 'SiteTree_Live.UserDefinedForm_Live' in 'field list'

    PHP:

    public function ShowFeedback()
    {
    //Hard coded ID for testing purposes
    return new UserDefinedForm_Controller(SiteTree::get()->byID(9));
    }

    Template:

    <% loop ShowFeedback %>
    $Form
    <% end_loop %>

    Question:
    I've written a very small and dirty module that lets the user choose which page to show a created userform on via the CMS. Everything works as expected, and if they attach an empty userform (no form fields created, only the page type created) everything works. As soon as a form field is added to the userform, the following error is shown on the page (not in the CMS).

    The strange thing is the form still displays on the page as expected, and even submits.

    So what am I doing wrong that is creating this error?

    Unknown column 'SiteTree_Live.UserDefinedForm_Live' in 'field list'

    Would love some insight to how I should resolve this issue.

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Userform Module - Strange error Link to this post

    I'm not sure what exactly is going on, but this is what I see at a first glance:

    In your template you are looping the returnvalue of ShowFeedback(). The loop structure would expect a DataList, but the ShowFeedback function returns a conrtroller. So I think that's something you should look at first.

    Martine

  • Peavers
    Avatar
    Community Member
    8 Posts

    Re: Userform Module - Strange error Link to this post

    Hi Martine,

    Thanks for the response, couple of questions:

    1. Isn't the result of the call to the controller what's being rendered? Which is ultimately going to be a datalist?

    2. If this wasn't the case, why would the form still render on the page after the big error screen, and still submit/function correctly? If it was expecting a datalist back, I also think there is a specific error code for that.

    PHP isn't my strongest language so I may just be missing the obvious here.

    353 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.