orchardcms - Orchard custom field not getting posted correctly -


i have created custom field in orchard meant contain 1 field (guid). whenever added content type, show new guid in "editor" template. works fine, except when submit form contains content type, form gets posted different guid. on looking closely, found driver of field editor (post) not updates viewmodel field.

any suggestion or tips debug ?

here lines of code

protected override driverresult display(             contentpart part, fields.uniqueidfield field,             string displaytype, dynamic shapehelper)         {              return contentshape("fields_string", // key in shape table                  getdifferentiator(field, part),                  () =>                  {                      var settings = field.partfielddefinition.settings.getmodel<uniqueidfieldsettings>();                      var value = field.id;                        var viewmodel = new uniqueidfieldviewmodel                      {                          id = value                      };                       return shapehelper.fields_string( // actual shape resolved (fields/datetime.cshtml)                          model: viewmodel);                  }              );         }          protected override driverresult editor(contentpart part,                                                fields.uniqueidfield field,                                                dynamic shapehelper)         {              var settings = field.partfielddefinition.settings                                 .getmodel<uniqueidfieldsettings>();             var value = guid.newguid().tostring();             field.id = value;              var viewmodel = new uniqueidfieldviewmodel             {                 id = value,             };              return contentshape("fields_string_edit",                 () => shapehelper.editortemplate(                           templatename: templatename,                           model: viewmodel,                           prefix: getprefix(field, part)));         }          protected override driverresult editor(contentpart part,                                                fields.uniqueidfield field,                                                iupdatemodel updater,                                                dynamic shapehelper)         {              var viewmodel = new uniqueidfieldviewmodel();                      if (updater.tryupdatemodel(viewmodel,                                        getprefix(field, part), null, null))             {                 field.id = viewmodel.id;             }              return editor(part, field, shapehelper);         } 

you resetting value every time in editor method, called post editor method every time @ end of own execution. set new value if there isn't 1 already.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -