[TYPO3-dev] enforcement of uniqueness of fields
Jochen Rieger
j.rieger at connecta.ag
Mon Apr 24 11:07:51 CEST 2006
Hi Martin,
>> 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.
as Markus already mentioned the DB query would be missed if the user
clicks the save button directly after typing in the value in our unique
field.
So the only possibility to avoid onkeyup might be to create a JS
function that is triggered via onClick on all the save buttons and
returns false in case of some unique alert in any of the fields. Makes
the whole thing a bit more complicated to build.
By the way I almost finished it last saturday. First tests (on my local
installation) went quite fine with the onkeyup triggering.
>> 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.
Yes, you are right. A small icon might be more appropriate.
>> - 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.
I used the existing functions now. Everything worked fine although I
think there should be some review and additional conception to integrate
everything more smoothly and clean.
>> 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.
Hmmmm ... I think it is not possible to avoid XCLASSing when creating an
extension. Please correct me in case I am wrong. But
class.t3lib_tceforms.php has to be patched. And a) there is no hook
around as far as I could find out and b) in my opinion a hook wouldn't
fit the needs of this feature.
So ... my plan now is to finish the patch, write a feature request in
the bugtracker and attach the files. Good plan? Well in that case maybe
an XCLASS is even the better solution, isn't it?
Regards,
Jochen
More information about the TYPO3-dev
mailing list