Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • shailesh 2 posts 22 karma points
    Dec 27, 2017 @ 12:49
    shailesh
    0

    In Umbraco contour Create New Field Type Not Showing Db Saved Value

    To add new richtext box editor in my form I followed below steps but i got half way success. 1) created new field type by adding below class inside app_code folder. public class RichTextEditor : Umbraco.Forms.Core.FieldType { //public umbraco.editorControls.tinyMCE3.TinyMCE tn; //public System.Web.UI.WebControls.TextBox tn; [Umbraco.Forms.Core.Attributes.Setting("DefaultValue", description = "Default Value")] public string defaultValue { get; set; }

    [Umbraco.Forms.Core.Attributes.Setting("Placeholder", description = "Place Holder")]
    public string placeHolder { get; set; }
    
    public RichTextEditor()
    {
        this.Id = new Guid("D6A2C406-CF89-11DE-B075-55B055D89593 ");
        this.Name = "RichTextEditor";
        this.Description = "Renders a html input";
        this.Icon = "icon-autofill";
        this.DataType = FieldDataType.LongString;
    }
    

    }

    2) In this path ..\Views\Partials\Forms\Fieldtypes I have created below new field type with name FieldType.RichTextEditor.cshtml and code looks like

    @model Umbraco.Forms.Mvc.Models.FieldViewModel

    <script type="text/javascript" src="@Url.Content("~/umbraco/lib/tinymce/tinymce.min.js")"></script>
    
    
    
    
    <script type="text/javascript">
    
    tinymce.init({
        selector: "textarea.rte",
        plugins: [
            "autolink autosave link image lists charmap preview hr anchor pagebreak spellchecker",
            "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
            "table contextmenu directionality emoticons template textcolor paste textcolor"
        ],
        toolbar1: "bold italic | link unlink | formatselect",
        //toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | inserttime preview | forecolor backcolor",
        //toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft",
        remove_linebreaks: false,
        relative_urls: false,
        menubar: false,
        toolbar_items_size: 'small'
    }); 
    

    ss @Model.Id // FOR SAMPLE I TRIED TO PRINT THIS VALUE AND IT ALWAYS NULL DON'T NO WHY

    3) Now From umbraco admin login I did added new answer type e.g richtexteditor and it get's also appeared at client side and I am able to save that content inside my database table e.g personaldetail_tbl -> remarks column inside form's .json file below tag automatically added { "caption": "General Remarks", "tooltip": null, "placeholder": null, "cssClass": null, "alias": "testEditor", "id": "9739aac1-6c8e-4f65-abf9-85a0fb2b93e7", "fieldTypeId": "d6a2c406-cf89-11de-b075-55b055d89593", "prevalueSourceId": "00000000-0000-0000-0000-000000000000", "dataSourceFieldKey": null, "mandatory": false, "regex": null, "requiredErrorMessage": null, "invalidErrorMessage": null, "condition": { "id": "00000000-0000-0000-0000-000000000000", "enabled": false, "actionType": "Show", "logicType": "All", "rules": [] }, "settings": { "defaultValue": "[%generalremarks]", "placeHolder": "", "HTML": "" }, "preValues": [] } Now main problem is that ,a data which saved inside table is html data and when i open my form again then already saved data's value not able to coming. i mean to say newly added field type values not getting updated on form ( which I already saved inside database )

Please Sign in or register to post replies

Write your reply to:

Draft