Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Userform Module - Strange error


Go to End


3 Posts   1059 Views

Avatar
Peavers

Community Member, 20 Posts

4 December 2013 at 10:09am

Edited: 04/12/2013 11:09am

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.

Avatar
martimiz

Forum Moderator, 1391 Posts

5 December 2013 at 12:37am

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

Avatar
Peavers

Community Member, 20 Posts

5 December 2013 at 7:53am

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.