[dokuwiki] Re: Improvements in form handling for plugins

  • From: "TNHarris" <telliamed@xxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 26 Jul 2007 17:29:34 -0400

On Wed, 25 Jul 2007 23:15:03 +0200, "Andreas Gohr" <andi@xxxxxxxxxxxxxx>
said:
> 2nd: attributes shouldn't be printed if empty (eg. class=""). I just
> pushed a patch for buildAttributes which should help with this.
> 

Ah, I had actually made that change but forgot to include it in the
patch.
Only thing is, empty() isn't well suited because it returns true for the
string "0".
Perhaps...?
  foreach($params as $key => $val){
    if($key{0} == '_' || ($skipempty && (is_null($val) || $val=='')))
    continue;
  ...


> 1st: The helper functions to create the elements are expecting their
> parameter in a not too optimal order.
> 
> I'd expect the following order:
>   type, name, value, label, id, class, attrs
> 

I see your point. Although with that order 'value' would be a required
parameter since 'label' is. Or should it use the name when 'label' is
empty? I think that'll work well. 'id' can default to empty and 'class'
to either "simple" or "block"? (I think "block", it's used most often in
inc/html.php.)
So...
  form_makeField($type, $name, $value=null, $label=null, $id=null,
  $class="block", $attrs=array())

(Is there much difference using "" versus null for default parameters?)

I'm going to add field psuedo-tags for 'Menu' (drop-down selection) and
'Listbox' (multi-item selection). I also think multiple fieldsets should
be allowed. So I'll change useFieldset() to startFieldset() and
endFieldset(). A fieldset will be implicitly closed when a new one is
started, or the form is printed. (In other words, no nesting.)
-- tom
telliamed@xxxxxxxxxxx

-- 
http://www.fastmail.fm - One of many happy users:
  http://www.fastmail.fm/docs/quotes.html

-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: