c# - Strange behavior in Orchard CMS Custom Forms -


i created new content type definition called signup text fields. created new custom form, option save content item once form submitted selected content type signup.

this works fine far. when create entry , want see in admin @ submissions, , click on content item, seethis

what doing wrong? don't know if saves content item

i assume you're using orchard 1.7.2, because custom forms broken in way in version (but it's fixed in 1.x branch, work in orchard 1.8 - coming soon).

the problem how content items saved, data not lost (and can retrieved), saved wrong table in db (contentitemrecord, instead of contentitemversionrecord). see issue on codeplex description on how apply dirty fix resolves problem (the fix needs applied "createpost" action in "orchard.customforms/controllers/itemcontroller".

here piece of code fixes existing submissions. have place controller module, e.g. orchard.users , available on route "„~/users/contactformentryfix". if place in other module you'll have edit namespace , you'll have change "_contenttypeid" property id of content type use custom form:

using orchard.contentmanagement; using orchard.contentmanagement.records; using orchard.data; using orchard.ui.admin; using system.linq; using system.web.mvc;  namespace orchard.users.controllers {     [admin]     public class contactformentryfixcontroller : controller     {         private readonly irepository<contentitemrecord> _contentitemrecords;         private readonly irepository<contentitemversionrecord> _contentitemversionrecords;         private readonly icontentmanager _contentmanager;         private const int _contenttypeid = 26;           public contactformentryfixcontroller(irepository<contentitemrecord> contentitemrecords, irepository<contentitemversionrecord> contentitemversionrecords, icontentmanager contentmanager)         {             _contentitemrecords = contentitemrecords;             _contentitemversionrecords = contentitemversionrecords;             _contentmanager = contentmanager;         }           public actionresult index()         {             var itemrecords = _contentitemrecords.table.where(record => record.contenttype.id == _contenttypeid);             var itemversionrecords = _contentitemversionrecords.table.where(versionrecord => itemrecords.select(record => record.id).contains(versionrecord.contentitemrecord.id));              foreach (var item in itemversionrecords) item.data = itemrecords.firstordefault(record => record.id == item.contentitemrecord.id).data;              var items = _contentmanager.query("contactform").list();             foreach (var item in items) _contentmanager.unpublish(item);              return content(string.format("{0} contact form version entry fixed , {1} contact form item unpublished.", itemversionrecords.count(), items.count()));         }     } } 

the submitted items unpublished security reasons (btw when using custom forms, make sure type use draftable , of course have saved upon submission, unless use workflow handle data).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -