More in this section

Forums / Developing with Sitefinity / Custom module with long strings in a field

Custom module with long strings in a field

2 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    21 Feb 2012
    Link to this post
    Hi,
    I've been experimenting with a custom module based on one of Josh Morales' posts.  I want to add a custom field called LeadText, but I'd like it to be able to persist something longer than 256 characters. 

    At first, I tried this:
    /// <summary>
    /// LeadText.  A summary version of the main content.
    /// </summary>
    [DataMember]
    public string LeadText
    {
        get { return this.leadText; }
        set { this.leadText = value; }
    }

    But discovered that the text was truncated (actually, I get an ORM error warning of the truncation).  So I decorated the attribute like this:
    /// <summary>
    /// LeadText.  A summary version of the main content.
    /// </summary>
    [DataMember]
    [UserFriendlyDataType(UserFriendlyDataType.LongText)]
    public string LeadText
    {
        get { return this.leadText; }
        set { this.leadText = value; }
    }

    However, this has no effect--I still get the warning about truncation. 

    How do I create a new field that is a long text field?  Or, if this is the correct approach, does OpenAccess upgrade a short text to a long text field, like Nolics did in 3.x?

    Thanks,
    Mike Sharp


  2. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    21 Feb 2012
    Link to this post
    Ah, never mind. I realized I needed to update the Fluent mapping as well. 

        itemMapping.HasProperty(p => p.LeadText).IsLongText(
    this.Context).IsNullable();

    This worked fine.

    Thanks,
    Mike
2 posts, 0 answered