views:

13

answers:

1

There's this cool new feature in SP 2010 where you can specify a custom validation formula and an error message for any column.

For some reason it doesn't work when you replace the default NewForm.aspx for a list with a custom form using SharePoint designer's "Create New List Form -> New Item Form". It creates an aspx where it puts a FormField control for every field of the selected content type instead of the ListFormWebpart which iterates and renderes every field with no fields explicitly mentioned on the page.

The code for every field on a just-created custom form is similar to the following (just to illustrate)

<tr>
  <td width="190px" valign="top" class="ms-formlabel">
    <H3 class="ms-standardheader">
    <nobr>PhoneNumber</nobr></H3>
  </td>
  <td width="400px" valign="top" class="ms-formbody">
    <SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="New" FieldName="PhoneNumber" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@PhoneNumber')}"/>
    <SharePoint:FieldDescription runat="server" id="ff4description{$Pos}" FieldName="PhoneNumber" ControlMode="New"/>
  </td>
</tr>

The problem is that with a "Create New List Form -> New Item Form" form the (new sharepoint 2010) formula validation doesn't work: it passes the validation on the form only failing on the save stage resulting in an error page.

Is it in any way configuarable with the FormField control or can I in any other way take benifit of this new sp2010 validation mechanism when using a custom (non-ListFormWebpart) item pages or do I have to write custom GUI validation in this case?

Thanks!

A: 

The problem is not with the FormField control itself, but with the DataFormWebPart web part I was using these fields in. There're 2 issues:

  1. With the uninquness the field throws an exception which should be correctly handled by the WebPart showing the message that an item with such value of the field already exists. But the DataFormWebPart doesn't handle this exception, while the default ListFormWebPart does. It is similar with the custom validation formula.
  2. SharePoint field controls implement the IValidator interface so that the owning WebPart can validate them and display appropriate messages (e.g. for required lookup fields), but the DataFormWebPart doesn't do that (The ListFormWebPart does)
axk