Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: John McClure <jmcclure@hy...> - 2011-08-29 19:49:33
|
badon wrote: > > How exactly should this validation be done? Do you do it in the form field > somehow? JMc: No > If you do it in the template, it will cause the original > previously existing page to have the error message, not just the new > duplicate one. JMc: True only if you store a duplicate. Don't store the duplicate - store an error message. > > I was thinking that if I could run the query just once, then only the new > duplicate page would have the error message. Then I could send a bot to > clean out the dupes automatically, while other queries on the site > automatically ignore them. The user could be made aware of the error, but > then just do whatever they wanted after that point, without worrying about > fixing it. > > Of course, I'm hoping they either move on to the next item the want to > submit, or add information to the previously existing item. > > But, I don't think it's straightforwardly possible to run a query just > once if it's in the template, where it will be run each time the page page > is refreshed. But, maybe it's possible to do the validation checking in > the form? JMc: It's not possible without rolling your own. > > For example, if I have a form field like this: > > {{{field|Serial number|mandatory}}} > > And I have a validation checking query that I have tested in the template, > like this: > > {{#if: {{#ask: [[Category:Stuff]] [[Serial number::{{{Serial number|}}}]] > | ?}} > | DUPLICATE! > | {{{Serial number|}}} > }} > > How do I get that template query to work for me into the form field? All > there is in the field is "Serial number", which is only a "field name" > according to the docs, not a parameter, or anything like that that can be > manipulated with parser function logic like #if. Am I mistaken about that? > I tried it, and didn't get it to work, but the odds are pretty high that > I'd get the syntax wrong without an example to follow. > > I can't see quite how to intercept a submitted form value for processing > before it is stored in the template. Doing the validation checking in the > template definition is actually altering it's value AFTER it is stored by > Semantic Forms as a parameter value in the page template. JMc: False. The template controls whether it is stored or not, *nothing happens behind the scenes* over which you have no control. > > So, I guess we need to be clear about what we mean by "storing" the serial > number: > > * Semantic Form field name > * Page template parameter > * Template definition parameter (and semantic property) > > That's the order that the serial number will be "stored". First it is > temporarily stored into the Semantic Forms field name, which I don't think > is something I can access. Then, Semantic Forms permanently stores it into > the page template parameter. Finally, the page template parameter sends > the serial number to the template definition parameter, JMc: ... which calls {{#set:}} or formats [[propname::value]] or does SOMETHING ELSE >where it is stored in the form of a semantic property. JMc: the template's logic determines whether it is stored or not. > > The only step that lets me change the value before it is permanently > "stored" is in the Semantic Form itself. Is it possible to manipulate that > value using a query that is only run once before, during, or after the > form stores the value in the page template parameter? JMc: Don't worry about the fact a query for a page with the same property value, is done every time the page is saved - the query is *not* done every time the page is displayed due to caching. As far as I know, there's no reason to mess with substitution. Hope that helps! John |