Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

html_options produces invalid HTML

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
pse
Smarty n00b


Joined: 16 Dec 2004
Posts: 2

PostPosted: Thu Mar 03, 2005 3:51 pm    Post subject: html_options produces invalid HTML Reply with quote

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 Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 03, 2005 4:12 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 03, 2005 4:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Mar 03, 2005 4:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 03, 2005 5:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Mar 03, 2005 5:35 pm    Post subject: Reply with quote

Quote:
If I don't define a selected option, then nothing shows up selected (?)


As it should be.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Mar 03, 2005 5:36 pm    Post subject: Reply with quote

correct, so where is the problem?
Back to top
View user's profile Send private message Visit poster's website
pse
Smarty n00b


Joined: 16 Dec 2004
Posts: 2

PostPosted: Fri Mar 04, 2005 8:21 am    Post subject: Reply with quote

Embarassed
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 Wink
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP