Developer forum

Forum » Development » Validating items/paragraphs editors

Validating items/paragraphs editors

Jan Sangill
Reply

Hi,

I have two questions:

1) In DW9, is it possible to custom validate all items/paragraph fields of the type editor. If criterias not met, then return to page with error message and without losing the text already entered? If so, which should be used? Any examples around?
2) When saving an item, manipulate deactivation column and prefill it on a certain item type. If so, which should be used? Any examples around?

//jan

 

 


Replies

 
Jan Sangill
Reply

bump:)

 
Nicolai Pedersen
Reply

Hi Jan

When defining an item type, you can set some validation on the field using the field settings - using regex - some buil-in or your own. See dump 1 and the manual on field validation:

http://doc.dynamicweb.com/documentation-9/content/items/item-types#2362

When items are saved, you can use a notification subscriber to manipulate data. You can use an ItemNotification.Saved notification subscriber:

http://doc.dynamicweb.com/Default.aspx?ID=8258#article=e0217aa0-53b1-28f7-0af2-ba57c35e7194

See an example here: http://doc.dynamicweb.com/forum/development/update-item-with-notificationsubscriber (DW 8 example, so it needs a little update)

BR Nicolai

Capture.PNG
 
Jan Sangill
Reply

Hi Nicolai,

Yes, I can manipulate the data in this example.

How would I go about validation the editor field though, this cant be done out of the box.

If I wanted to show an error message to the user, if they did something wrong when entering text in the field editor.

Only way I can think of at the moment on how to achieve this, is to manually add JS validation in ParagraphEdit.aspx.

If this could be avoided, I would like too.
Is it possible somehow to extend the ParagraphEdit.aspx template via API? Or returning an error message to user somehow else?

 

 

 
Nicolai Pedersen
Reply

Hi Jan

I cannot see any possible solution to this as it is now. You can alwasy go to the raw request (BeforePreRequestHandlerExecute notification) and see if something is posted to ParagraphEdit.aspx and if the post has a field with data from an editor, validate that data, stop the response, display an alert in JS in the resonse and when clicked ok, redirect back... Bad solution, but best option as I see it right now...

BR Nicolai

 
Jan Sangill
Reply

Hi,

Ok ty.

I just saw today an plugin for ckeditor:
http://sdk.ckeditor.com/samples/accessibilitychecker.html - a11ychecker

Had some issues with it not responding to me, dont know why. Created a support case for it, dont know if that was correct or should have been in the forum:(
If I can get that to work, then I think I am perfect.

 

You must be logged in to post in the forum