10375 Posts in 2190 Topics by 1707 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 271 Views |
-
Can't extend UserDefinedForm (Unknown column 'UserDefinedForm.Version' in 'field list')

21 January 2013 at 11:30am Last edited: 21 January 2013 12:22pm
Hey guys,
I thought this would be a very easy thing to accomplish, but have been struggling with this for hours now. Basically what I want to do is have a page type that lets you create a form (have all the functionality of UserDefinedForm), PLUS a file upload field to upload a PDF.
Isn't that just extending UserDefinedForm like this?:
<?php
class DokumentoPuslapis extends UserDefinedForm {
public static $has_one = array(
'Taisykles' => 'File'
);public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.PDF', new UploadField('Taisykles'));
return $fields;
}}
class DokumentoPuslapis_Controller extends UserDefinedForm_Controller {
public function init() {
parent::init();
}
}Trying to access a newly created page of this type for editing gives me this:
[User Error] Couldn't run query: SELECT DISTINCT "SiteTree"."ClassName", "SiteTree"."Created", "SiteTree"."LastEdited", "DokumentoPuslapis"."TaisyklesID", CASE WHEN "SiteTree"."ClassName" IN ('SiteTree', 'Page', 'DokumentuKatalogas', 'KontaktuPuslapis', 'NaujienosPuslapis', 'NaujienuKatalogas', 'PagrindinisPuslapis', 'PereinantisPuslapis', 'ErrorPage', 'RedirectorPage', 'VirtualPage', 'UserDefinedForm', 'DokumentoPuslapis', 'DokumentuPuslapis') THEN "SiteTree"."Version" WHEN "SiteTree"."ClassName" IN ('UserDefinedForm', 'DokumentoPuslapis', 'DokumentuPuslapis') THEN "UserDefinedForm"."Version" ELSE NULL END AS "Version", "SiteTree"."ID", CASE WHEN "SiteTree"."ClassName" IS NOT NULL THEN "SiteTree"."ClassName" ELSE 'SiteTree' END AS "RecordClassName", "SiteTree"."Sort" FROM "SiteTree" LEFT JOIN "DokumentoPuslapis" ON "DokumentoPuslapis"."ID" = "SiteTree"."ID" WHERE ("DokumentoPuslapis"."ID" = 41) AND ("SiteTree"."ClassName" IN ('DokumentoPuslapis')) ORDER BY "SiteTree"."Sort" ASC LIMIT 1 Unknown column 'UserDefinedForm.Version' in 'field list'
GET /ss3/admin/pages/edit/show/41Line 580 in C:\wamp\www\ss3\framework\model\MySQLDatabase.php
Might this have to do with me recently installing the Translatable module? Or is my code simply wrong?
EDIT: After some fiddling I came up with a partial solution.
<?php
class UDFDecorator extends DataExtension {
static $has_one = array(
'Taisykles' => 'File'
);
public function getCMSFields() {
$this->extend('updateCMSFields', $fields);
return $fields;
}
public function updateCMSFields(FieldList $fields) {
$fields->push(new UploadField('Taisykles', 'Prisegamas failas'));
}
}_config.php:
Object::add_extension('UserDefinedForm', 'UDFDecorator');
Still, that makes ALL the forms have this functionality. Shouldn't extending the UDF class work?
-
Re: Can't extend UserDefinedForm (Unknown column 'UserDefinedForm.Version' in 'field list')

21 January 2013 at 11:48pm
I have this same problem too.
Reading through the SQL it seems that the version column can't be found because the UserDefinedForm table isn't included in the list of tables to query.
I too added a field to my extended class, if I remove the extra field I don't get the error. I think the problem may be due to the code that builds the table list and I wonder whether a combination of your two approaches would work; i.e. extend UserDefinedForm and then decorate the extended class to add the additional fields you require. -
Re: Can't extend UserDefinedForm (Unknown column 'UserDefinedForm.Version' in 'field list')

22 January 2013 at 4:49am Last edited: 22 January 2013 5:00am
Thanks for the reply, FungshuiElephant!
I tried your suggestion. Unfortunately, that still produces the same error here :/
... the UserDefinedForm table isn't included in the list of tables to query.
Regarding UserDefinedForm: did you check the database to see whether such a table exists? Because my DB didn't even have one with such a name. -
Re: Can't extend UserDefinedForm (Unknown column 'UserDefinedForm.Version' in 'field list')

22 January 2013 at 5:48am
I definitely have a UserDefinedForm table, along with UserDefinedForm_versions and UserDefinedForm_Live.
I think the problem here is caused by the versioning; both SiteTree and UserDefinedForm are versioned objects. I looked through the code and this seems to be catered for, i.e. you can have an object that's versioned twice; in fact that's where the case statement in the SQL code comes from.
The code that generates the SQL statement thinks that it's only looking for fields on SiteTree and your new extended class, it's not interested in the fields on UserDefinedForm so it doesn't include that table in the SQL and the bit of code that augments the query to do the versioning stuff is after the code to choose the tables. (See getFinalisedQuery in DataQuery in SSv3.0.3).
I think that's a bug.
I've submitted a ticket with a patch to fix this and another bug which got in the way of debugging this.
-
Re: Can't extend UserDefinedForm (Unknown column 'UserDefinedForm.Version' in 'field list')

22 January 2013 at 5:53am
Sweet! Hoping they'll fix this soon.
-
Re: Can't extend UserDefinedForm (Unknown column 'UserDefinedForm.Version' in 'field list')

20 March 2013 at 5:48am Last edited: 20 March 2013 6:12am
Update: I just downloaded the very latest version of Userforms from Github and replaced, then ran dev/build and this is working for me now.
| 271 Views | ||
|
Page:
1
|
Go to Top |



