Welcome Guest, Not a member yet? Register   Sign In
form_dropdown -> optgroup validation issue
#1

[eluser]xpix[/eluser]
Hi

I am using the form dropdown functionality like

Code:
<div class="formrow">&lt;?= form_label('Program: ', 'program') . form_dropdown('program',$programs_list);?&gt;</div>

The output is:

Code:
<div class="formrow"><label for="program">Program: </label><select name="program">
<optgroup label="0">
</optgroup>
<option value="113">aaaaaa</option>
<option value="114">bbbbbb</option>
<option value="116" selected="selected">ccccc</option>
<option value="115">ccccc</option>
</select></div>


The page doesn't validate on w3.org because of the optgroup. As you can see I have no need for the optgroup. Is there a way I can remove this tag?

Thx
#2

[eluser]Bill the Grue[/eluser]
<optgroup> is valid html (at least these guys think it's valid)

What doctype are you using?

Is optgroup the first validation error?
#3

[eluser]xpix[/eluser]
It's the first error

Code:
#  Error  Line 89, Column 11: end tag for "optgroup" which is not finished

</optgroup>



Most likely, you nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, in HTML the &lt;head&gt; element must contain a &lt;title&gt; child element, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.

I also use the formdropdown as multi select but I do not get this problem. Weird.
#4

[eluser]Evil Wizard[/eluser]
The html validation error is because the <optgroup> tag is expecting to contain child elements, that is why it is unfinished, either contain the list within the optgroup or omit it.
Code:
<div class="formrow">
    <label for="program">Program: </label>
    <select name="program">
        <option value="113">aaaaaa</option>
        <option value="114">bbbbbb</option>
        <option value="116" selected="selected">ccccc</option>
        <option value="115">ccccc</option>
    </select>
</div>
or
Code:
<div class="formrow">
    <label for="program">Program: </label>
    <select name="program">
        <optgroup label="0">
            <option value="113">aaaaaa</option>
            <option value="114">bbbbbb</option>
            <option value="116" selected="selected">ccccc</option>
            <option value="115">ccccc</option>
        </optgroup>
    </select>
</div>
#5

[eluser]xpix[/eluser]
Finally I found the problem

I was giving a multidimensional array not a regular one.




Theme © iAndrew 2016 - Forum software by © MyBB