I'm looking for a custom text field that generates an extra text field when needed. Similar to the way a template adds new text fields.
For storage all values can be saved as one comma separated string (or pipe).
Does anyone know if this exists already? I searched the Sitecore marketplace google but haven't found what I need yet.
edit: If none exists yet I will probably make it myself with this reference: https://sdn.sitecore.net/Articles/API/Creating%20a%20Composite%20Custom%20Field.aspx
Since I do need the labels (which need to be translated) and the name value list field doesn't allow duplicate keys we changed our approach.
this was going to be used to input multiple phone numbers, e-mail addresses etc.
In stead we opted to go with separate templates that would be inserted as child items.
Related
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.
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
I am new with Orchard and can not seem to get past this problem.
Goal
to be able to specify two text values on each page and show those in a styled DIV if they are not blank.
Procedure
I created a new content part in Orchard's admin named
"InnerPageTitleArea"
I added two fields to this part: IpTitle (Text Field) and IpSubtitle
(Text Field)
I added this part to the Page content type
Those textboxes show when editing a page, and I filled them in on
several pages
Those values show on pages they were entered on (all good so far)
The problem:
I want to provide a template for the InnerPageTitleArea, but all
attempts have failed.
When using shape tracing, there are no alternates referencing my
part alone
All alternates begin with "Fields" i.e.
~/Themes/MyTheme/Views/Fields.Common.Text-InnerPageTitleArea.cshtml.
If I use one of those field alternates, my template is repeated
twice - once for each field
If I use a field-specific template, i.e.
~/Themes/MyTheme/Views/Fields.Common.Text-InnerPageTitleArea-IpTitle.cshtml
I can actually get at both values, but then the other value
(IpSubtitle) still displays as plain text. I could probably remedy
that with Placement.info, but I suspect that I am just lacking some
fundamental understand of Orchard.
What to do?
Your part never renders anything because it doesn't have a driver that would create a shape. The only shapes that are getting out of that part are the shapes for each of the fields. The simplest way to get what you want is to create one alternate for each of the fields. Would that work?
I'm working on a Sitecore implementation where there are many forms throughout the site (before you ask, WFFM is out of the question!).
My question is, what is the best way to store the form labels? My current thinking is to use a dictionary structure and access form field labels by key. The problem with this approach is when editors want to vary the label for the same field; e.g. on form X the first name field is "First Name" then perhaps somewhere else it could be "Forename" or maybe it's a required field (with asterisk) in one place an optional in another. I don't really want to start having dictionary items called "FirstNameWithAsterisk" and "FirstNameWithoutAsterisk" etc.
One other thought I've had is to simply store the form labels in a Name Value List field. This field could then be populated with Names/Values like and editors would be free to use whatever form labels they like, without risk of inadvertently editing a dictionary entry used somewhere else.
I've been down the route before of having form fields on the page template, but this is a pretty horrible solution IMHO so I wouldn't be interested in going down this route again.
EDIT
To confirm, there are a finite number of forms for this site.
I would go with the dictionary approach. If your argument is that it could vary, then that's a reason to logically separate them. So, it sounds like you have custom forms and a finite set of forms to be built (please confirm). That said, build your dictionary just like that, e.g.
Form1
Form1-FirstName
Form2
Form2-FirstName
Or another naming convention that makes sense for you.
Logically its the "first name field" for each unique form, but they're technically two separate unrelated things, hence you would want two dictionary items for them. You could do this via a naming convention that you alluded to, but don't name them based on the content, (since that value changes!), instead name it based on what it applies to / where it's used since your code will statically refer to the key.
So I would say FirstNameWithAsterisk and FirstNameWithoutAsterisk are bad names because they tie to the content and whether it has or doesn't have an asterisk. Instead, name it by the form it applies to or some other general notion of the content.
Edit: Since the same form component can be added to more than one page then this is a perfect case for a data source of that presentation component. Simply create a template for all of the form fields, then create any number of instances of those and for each form bound to a page, point its data source to the respective item with the desired field values.
You know there is a built-in Dictionary in Sitecore, right? Take a look at a System/Dictionary. Then get values from it by calling Sitecore.Globalization.Translate.Text().
If you're for sure not going to support multiple languages... then you could conceivably co-opt this feature and make different language versions of the dictionary items actually be the different values you want for the field labels.
Can I populate a droplist in sitecore with a list of values by directly specifying them in the source field like Apples|Oranges|Grapes and have them show-up on the template instead of actually creating items for each value and then writing a query pointing to the parent?
There is no default functionality for this. The typical approach would be to create a folder containing items with each of these names, and set that folder as the source of a standard droplist field. But I would use droplink instead of droplist, because then you have strong references by ID rather than weak references by name, and those references appear in the links database.
Alternatively, you could probably achieve this by overriding the droplist control.
/sitecore/System/Dictionary might be a good home for the values you need to create in this context. Adding them to the Dictionary also makes them localizable and allows users to reference them as tokens in other fields if desired.
You might also find this article to be of interest. It goes into some detail about other uses for Dictionary items and Tokens.
Also, Sitecore's Reusing and Sharing Data guide has additional information on how to use Dictionary items and looks at other situations where you might want to inject simple values into items: