Sitecore Rich Text Field Max Length - sitecore

Is there a way to set a Max Length for characters entered into a Rich Text field in Sitecore 7.5? For example, I have an MVC View Rendering that displays quotes but the front end elements are designed so that the characters need to be within the parameters otherwise it looks awful. Personally I would rather have the CSS handle this but I'm not a front end dev and the client wants what the client wants :)

You have a apply a Validation Rule to the field on your template. When you select the Field under your template there is a Validation Rules section where you can select which rules to apply, there are 4 fields for different types of validation. Create a copy of the /sitecore/system/Settings/Validation Rules/Field Rules/Sample/Max Length 40 and set the MaxLength in parameters field.
Using Sitecore Field Validators
These rules however do not stop the user from saving the Item, they only provide warnings either next to the field, to the Validator bar or require the user to manually click Review > Validation. Another option is to set a RegEx in Validation and the error message in ValidationText field.
Sitecore Custom Field and Item Validation Basics
In both cases, since you are using a Rich Text Field it will be possible for the user to style the text. Be aware that the default MaxLength validator will probably include the HTML markup text in it's length count, whereas you are probably only interested in the actual text length. If this is an issue then you can create your own custom validator, strip out any markup and then check the length.

Related

Why doesn't Web Forms for Marketers correctly populate the selected DropList value in my custom save action?

Inside my custom save action, I iterate through the form fields (the AdaptedControlResult objects). Any form field which is a DropList (from any source -- manually entered values, or an item lookup) is returning a string value of System.Collections.Generic.List`1[System.String]
Now, it's important to know, it's not returning an actual List. It's returning a literal string with that value.
So, this call:
fields.GetEntryByName("MyFieldName").Value
Is returning the string: System.Collections.Generic.List`1[System.String]. Not the value of the dropdown. A string saying that's it's a List<string>.
I have confirmed the HTML of the form is rendering correctly. I have manually checked the inbound HttpContext.Current.Request.Form values as well...
HttpContext.Current.Request.Form["BGWnjkQqrE6w6sr31IgzrQ.Sections[5].Fields[0].Value"]
That is the correctly-selected value of the drop down (a Sitecore ID).
So, the data is getting output to the form correctly, and the inbound Request.Form data is also correct. Somewhere, Sitecore is deciding not to populate the selected value into the AdaptedControlResult object.
What's additionally odd is that for DropList field types, the selected value does appear in the Parameters property (inexplicably). I would just detect this and use it, but it's not consistent -- for instance, for textbox field types, the word "multiline" appears there.
All other field types work fine -- I have several text entry fields, and some radio button lists. It's just DropList fields.
What is the trick to getting this?
This is a known bug in Sitecore when using the WFFM module in MVC. You can find more details in this Knowledge Base Article - Incorrect data is saved for list fields in WFFM MVC.
The fix is listed on the kb article and depends on the exact version of Sitecore you are using. Sorry to provided a link only answer but there are multiple steps reqiured for the fix and the download for the fix is attached in the article.

sitecore fields data type for xml data

I will need to save a serialized data in a field. Can anybody please help me figure out how can i do it in sitecore.
In a sql server I can define xml field-type which is sufficient for this. But similarly I can't find anything in sitecore. Though there are two types called html & memo which are deprecated. Also want to know can I use any of these.
We are using sitecore 7.2 BTW.
You can simply store it in a multi-line text field. If you wanted to get real fancy then you could create a custom field type. I've previously even used an IFrame field type for this kind of data, since the text is blanked out to the end user (but still viewable using Raw Values) and since the underlying data is just text it worked fine.
In any case, if your field is populated automatically from an external source then you probably don't want that data editable from the content editor. Lock the field down using the security editor and using correct roles & permissions so that normal editors do not have Field Write permissions (set on the template itself, not the created items)
In Sitecore, all fields are internally kept as strings by design (except media blobs). I think the best field type to store serialized XML would be multi-line text.
Of course, you should care about all serialization and deserialization the data into that field

Custom Validation in Ektron Smartfrom Definition

I am working in Ektron 8.7.
I am trying to add a custom validation logic to my smartform definition.
I have a check box and text box fields in my smartform definition,i need to make the text box read only if the check box checked property is true.
The custom validation options available in the smartform editor fields doesn't have any such option.
How can i achieve this?
I have gone through custom validation knowledge base article in ektron(http://dev.ektron.com/kb_article.aspx?id=7420).
But i couldn't get the property of smartform element
in order to define the logic.Is this possible through XSLT?
Making a text box read only if a check box is checked doesn't really fall into 'validation' -- sounds like you want to use the relevance feature, which allows you to hide or show form fields based on values of other fields. For example, you could show a read only version of the field when the check box is checked, and an editable version when it is unchecked. You can additionally apply validation logic on the text box that's displayed. Here are some related resources to help you get going with this http://bit.ly/cXiaKd -- http://bit.ly/11gedde

Sitecore Web Forms for Marketers - Complex custom field

The client wants to be able to display, within a WFFM form, a list of Sitecore items (each item containing an image & some HTML text), each item next to a checkbox to allow the end user to pick one or more of these items.
Within the form designer, for this particular field, we would like to have an item selector which can be used by the content editor to pick and choose which items to display in the list.
Is this something feasible in WFFM? Are there examples of complex custom form fields that I could take a look at? Thanks!
I just found out that what I asked can be easily accomplished with the ChechboxList field type already provided by WFFM and some CSS styling to handle the content of each item.
Thanks and sorry for the post.

What is the best UI for selecting tags from a list of existing tags?

I am using django-tagging. My model simply contains a field with a comma separated list of tags. I would like the user to be able to select tags from a list of already existing tags and also allow the user to add tags. Still resulting a comma-separated list of tags. How would I do that?
A pull down list doesn't work. I was thinking about simply listing all tags beneath the tag field and when a user clicks on an existing tag this is added to the tag field with a bit of javascript.
Other ideas are very welcome.
If you can use jquery there are several plugins to handle this and save you the JS coding:
Tag Suggest which can handle comma delimited tag lists and Autocomplete which also has the advantage of being used by Jannis Leidel's excellent autocomplete form widget for ForeignKey model fields
Having a separate complete list is a good start. I would also suggest an autocomplete implementation while the user is typing a tag name into the box. This helps eliminate the problem of having Batman and Bat-man and Bat Man as three separate tags.
I think your proposal of showing all tags and allowing the user to select them individually is a sound approach. Delicious.com uses this exact interface and it works wonderfully.
How about implementing it the same way Stack Overflow does for the ignored and interesting tags on the front page? Wait for the user to start typing, and as they do, fire off AJAX requests to the server and start returning the five most likely results, which you can then display in a hovering white box below the text box.