View previous topic :: View next topic |
Author |
Message |
pse Smarty n00b
Joined: 16 Dec 2004 Posts: 2
|
Posted: Thu Mar 03, 2005 3:51 pm Post subject: html_options produces invalid HTML |
|
|
Hi all,
This is a small bug : this plugins produces HTML code which is not valid when 'selected' attribute is specified because selected value is written into output before options, eg (if 'b' is specified as 'selected' value) :
Code: | b<option label="A" value="a">A</option>
<option label="B" value="b" selected="selected">B</option>
<option label="C" value="c">C</option>
|
I've patched function.html_options.php line 73 :
Code: | // Start patch PSE : should not write selected option first (not valid HTML)!
// $_html_result = $selected[0];
$_html_result = '';
// End patch PSE |
Not very important, but my validation reports for HTML code are clean now |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 03, 2005 4:12 pm Post subject: |
|
|
Can you post a test case? I can't reproduce the problem.
Here is mine:
index.tpl:
[php:1:55dc8a231e]<?php
require('./libs/Smarty.class.php');
$smarty =& new Smarty();
$smarty->assign('name', 'bob');
$smarty->assign('ids', array(1,2,3,4,5));
$smarty->assign('out', array('one','two','three','four','five'));
$smarty->display('index.tpl');
?>[/php:1:55dc8a231e]
index.tpl:
Code: | {html_options values=$ids output=$out selected="4"} |
OUTPUT:
Code: | <option label="one" value="1">one</option>
<option label="two" value="2">two</option>
<option label="three" value="3">three</option>
<option label="four" value="4" selected="selected">four</option>
<option label="five" value="5">five</option> |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 03, 2005 4:16 pm Post subject: |
|
|
I don't even see the code you are referring to in the html_options function, are you using the lastest release of Smarty? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Mar 03, 2005 4:28 pm Post subject: |
|
|
I think he is saying that the options shouldn't have the first option as the selected option. Which I don't understand because either way is valid HTML and afaik, also valid xhtml. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 03, 2005 5:33 pm Post subject: |
|
|
If I don't define a selected option, then nothing shows up selected (?)
Code: | {html_options values=$ids output=$out} |
Code: | <option label="one" value="1">one</option>
<option label="two" value="2">two</option>
<option label="three" value="3">three</option>
<option label="four" value="4">four</option>
<option label="five" value="5">five</option> |
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Mar 03, 2005 5:35 pm Post subject: |
|
|
Quote: | If I don't define a selected option, then nothing shows up selected (?) |
As it should be. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 03, 2005 5:36 pm Post subject: |
|
|
correct, so where is the problem? |
|
Back to top |
|
pse Smarty n00b
Joined: 16 Dec 2004 Posts: 2
|
Posted: Fri Mar 04, 2005 8:21 am Post subject: |
|
|
Oups, I've just checked 2.6.6 original code and seen that the bugged line was correct !
Someone in the project must have changed the class, I will investigate it....
PS : maybe initial problem was not clear : selected value was inserted before options tag, eg (b<option ....><option ...>...).
Sorry for this irrelevant thread. Next time I'll check original code |
|
Back to top |
|
|