[pmwiki-devel] adding features to input tags: best practice?

Dominique Faure dominique.faure at gmail.com
Thu Nov 16 03:27:53 CST 2006


On 11/15/06, Ben Stallings <Ben at interdependentweb.com> wrote:
> Thanks, Caveman, for reminding me of the server-side validation provided
> by ZAPdata.  I'll plan to have DataQuery produce ZAPdata code instead of
> reinventing my own server-side validation.
>
> However, I still feel like DataQuery needs some client-side validation
> as well, since it can be a pain to fill out a form and submit it, only
> to find that you typed a date in the wrong format, especially if
> $EnableIMSCaching=0, so that when you go back to the form, everything
> you typed is gone!  And I'd also like to continue the automatic
> tabindexing feature of UpdateForm, because it makes data entry so much
> easier.
>
> So that brings us to Dom's project:
>
> Dominique Faure wrote:
> > Few weeks ago, I did some experiments around it, but hadn't enough
> > time/needs to push them further. Anyway, here's my FormExtensions
> > recipe skeleton code that you may use as a starting point
> [...]
> > Perhaps, should I make it a recipe by itself, you (and other form
> > extensions recipes) could bet on?
>
> Yes, please!  If you'll draft a recipe file that usurps the input
> markup, I'll splice in the mask and auto-tabindex features from
> UpdateForm.  Thanks!  --Ben
>
Taking a wider perspective on it, I really think this should be made
directly available in the core. The code overhead would be minimal and
will truly open nice perspectives for form recipe authors, without the
need to use the dirty kludge I previously posted in this thread. For
example:

function InputMarkup($pagename, $type, $args) {
  global $InputHandlers, $InputTags, $InputAttrs, $InputValues, $FmtV;
  $ih = @$InputHandlers[$type];
  if(isset($ih)) return $ih($pagename, $type, $args);
  if(!@$InputTags[$type]) return "(:input $type $args:)";
  $opt = array_merge($InputTags[$type], ParseArgs($args));
  #...
}

Meanwhile, feel free to use the ideas behind the provided code (BTW,
this would be required to enable compatibility with 2.1 releases).

Dom



More information about the pmwiki-devel mailing list