| 
	
 | 
 Posted by David Haynes on 06/21/06 00:18 
Chung Leong wrote: 
> David Haynes wrote: 
>> I was thinking about this at a finer-grained level than you seem to be 
>> in that I was thinking that msch-prv was thinking of automating the 
>> common HTML elements rather than doing something more complex. 
>  
> Well, it isn't really automation, since you still need to write the 
> function call. Basically you're trying to communicate to the computer 
> that you want an input element at that location. Using HTML as the 
> language for this purpose guarantees full flexibility. You don't really 
> gain much using PHP. 
 
I was just thinking about the millions of times I have done something like: 
 
if( ! empty($foos) ) { 
   printf("<select name=\"%s\">\n", $select_name); 
   foreach( $foo as $foo ) { 
      $selected = ($foo['bah'] == 'xxx' ) ? 'selected' : ''; 
      printf("<option value=\"%s\" %s>%s</option>\n", $foo['value'],  
$selected, $foo['label']); 
   } 
   printf("</selected>\n"); 
} 
 
and was hoping that it could all be made simpler as something like: 
$attributes = array('name' => 'foo'); 
htmlSelect($attributes, $foo); 
 
in the hopes that the meaning for the page became clearer. 
 
Maybe I'll play with this when I get a little more free time. 
 
-david- 
 
BTW: Why doesn't the foreach() handle the !empty() case? It would make  
more sense IMHO.
 
  
Navigation:
[Reply to this message] 
 |