[TYPO3-dev] enforcement of uniqueness of fields

Martin Kutschker Martin.Kutschker at n0spam-blackbox.net
Mon Apr 24 09:41:38 CEST 2006


Jochen Rieger schrieb:
> Hi Martin, Markus and Kasper,
> 
>> Maybe only the warning could be presented to the user. But I don't 
>> think that an AJAX check is harder to implement.
> 
> as I also ran into that problem I decided to develop an AJAX check.
> 
> My concept:
> 
> If a field is supposed to be unique or uniqueInPid I am adding an 
> eventhandler (onkeyup) to the <input> field to trigger the AJAX request. 

Why not onchange? With onkeyup the check will be done for each letter you type.

> Beside that I am adding a <span> behind the <input> field where the 
> warning message is to be displayed in case the actual field value 
> already exists in the DB table / on the page.

Fine though beware the wizards which might be next to the field. I don't 
know if there's enough room for. Perhaps a warning icon with a tooltip is 
better.

> Unfortunately I do not have too much core-knowledge yet. So I might need 
> some advice. What I figured out so far:
> 
> - class.t3lib_tceforms.php needs to be edited from around line 1000
> - I am adding JS code via $this->additionalJS_pre[]
> - I try to use the methods of class.t3lib_ajax.php

AFAIK this file is stillborn. IMHO it has not been decided how AJAX will be 
used in a general way in TYPO3. Use it if you want and it suits your need, 
but if you need a quick solutions just use whatever seems fit to you.

> My questions / issues:
> 
> 1) Where to put the PHP code that is called by the AJAX request and 
> checking against DB? In an own file?

If you're creating an extension use a new file an avoid XCLASSing when 
possible.

> Into an existing one? Maybe we 
> should create a general AJAX-response class that gets an action parameter?

See my comment above.

> 2) If t3lib_ajax::getJScode() is called several times within a page (as 
> is the case in alt_doc.php when editing records) then the basic 
> functions will get overwritten all the time. Not very nice, isn't it? 

Don't know enough of the current t3lib_ajax.

Masi




More information about the TYPO3-dev mailing list