[pmwiki-devel] function InputDefault

Patrick R. Michaud pmichaud at pobox.com
Mon Jul 14 17:45:12 CDT 2008


On Mon, Jul 14, 2008 at 11:08:49PM +0100, Hans wrote:
> While you look at that function, could you please consider also
> to expand the 'if (@$args['request'])' routine so it can handle
> single-depth array input from GET or POST? Input forms elements can
> be part in an array. This is especially common for select input.
> ...
> For InputDefault section 'if (@$args['request'])' I suggest something
> like this, which works well:
> 
>   if (@$args['request']) {
>     $req = array_merge($_GET, $_POST);
>       foreach($req as $k => $v) {
>         if (is_array($v)) {
>           foreach($v as $kk => $vv)
>             if (!isset($InputValues[$k][$kk]))
>               $InputValues[$k][$kk] = 
>                 htmlspecialchars(stripmagic($vv), ENT_NOQUOTES);
>         }
>         else if (!isset($InputValues[$k]))
>              $InputValues[$k] = 
>                 htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
>      }
>   }

At the moment I disagree with this a bit as written above --
shouldn't the control name have a [] or something to indicate that
it's an array?

Also, I think we'd need to update the InputToHTML() function
to be able to handle arrays (since the whole purpose of
$InputValues is to be able to set things to be used by
(:input:) controls).

Pm



More information about the pmwiki-devel mailing list