Re: [Phphtmllib-devel] Usability issues
Status: Beta
Brought to you by:
hemna
From: Walter A. B. I. <wab...@bu...> - 2002-06-06 19:19:53
|
> I'm for improving the API and usability. If you are going to change > the API, the best time is at a major version (1.0.3 -> 2.0). --agreed. As long as its not too much of a break. :) So I went ahead and changed the constructor to accept n number of content items, and I have checked my apps I have built here at work, and it seems to not have broken anything. > Another API change that I suggested before is switching the label and > value in the form_select() convenience function. It would allow calls > like this: > > $form = form_select('example', ('zero', 'one', 'two')); > > rather than this: > > $form = form_select('example', (0=>'zero', 1=>'one', 2=>'two')); > > The patch for this is simply: > > --- phphtmllib.orig/tag_utils/form_utils.php Fri Apr 5 14:29:45 2002 > +++ phphtmllib/tag_utils/form_utils.php Tue Apr 23 21:02:01 2002 > @@ -294,7 +294,7 @@ > > $select = new SELECTtag( array("name" => $name) ); > > - while( list($label, $value) = each($options) ) { > + while( list($value, $label) = each($options) ) { > $selected_value = ""; > if ($value == $selected) { > $selected_value = "SELECTED"; ---ah yes. I think you have wanted this one for a while no? I know this will break a lot of pages I have that use select tags. I guess when I built this function it seemed to make sense to me to have the array be label=>value, as in tag attributes, instead of value=>label. Switching the array to be value=>label would make it easier to read in the cases where the value is an int 0,1,2,3. But in the cases where its some string it seems to make more sense to have it label=>value so you would do array("California" => "CA", "Texas" => "TX"); instead of array("CA" => "California", "TX" => "Texas"); to give u <select ...> <option value="CA">California</option> <option value="TX">Texas</option> </select> thoughts? |