[pmwiki-users] Building form with arbitrary data

V.Krishn vkrishn4 at gmail.com
Sun Oct 21 04:15:59 CDT 2012


On Sunday, October 21, 2012 11:20:39 AM Petko Yotov wrote:
> V.Krishn writes:
> > On Saturday, October 20, 2012 07:02:28 AM Petko Yotov wrote:
> > > This page may be helpful:
> > >   http://www.pmwiki.org/wiki/Cookbook/InputDefault
> > 
> > Thanks, I think this should help.
> > 
> > 1. Also can there be support for multiple select,
> > as suggested in comments on this page.
> > 
> > I tried making some changes to InputToHTML function:
> >         $opt[$checked] = in_array(@$opt['value'],
> >    
> >    (array)explode(',',str_replace(' ','', $InputValues[$name])))
> >    
> >                          ? $checked : false;
> 
> You don't need this change, just set your $InputValues as an array:
> 
>   $InputValues['color'] = array('red', 'green');

:-) This allows multiple defaults.

I was trying to set with (:input default ..... 
Is this already implemented? 
If not I would vote/request for such feature.

> 
> > and was able to see multiple selects.
> > I hope there are not more changes required for this feature.
> 
> Actually, assuming that a comma is a separator will mean that a comma can
> never be part of the value. For example, you wouldn't be able to have
> checkboxes like "Austin, TX", "Los Angeles, CA" and "Paris, France".

True,  the change was a testing, there needs to be a better check/option for 
separator and cleaning space.

Assuming the multiple input to be csv style text.
A better option: (for PHP 5 >= 5.3.0)

  $t = is_array($InputValues[$name]) ? 
       $InputValues[$name] :  str_getcsv($InputValues[$name]);
  $opt[$checked] = in_array(@$opt['value'], 
        preg_replace(array('/^\s/', '/\s$/'), '', $t)) ?
        $checked : false;

-- 
Regards.
V.Krishn

> 
> Also, as admins are already using the current implementation, the change
> you suggested will break their wikis when they upgrade. We normally try to
> not do this when we can.
> 
> Petko
> 
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://www.pmichaud.com/mailman/listinfo/pmwiki-users





More information about the pmwiki-users mailing list