2014-06-05 155 views
1

。你好,你好!我试图在表单上有多个选项的选择输入。我有几个这些,但由于某种原因,没有显示其所有选项。我尝试删除#,更改顺序以找出哪一个具体导致错误,并以不同的格式编写选项,但都没有成功。如果你有任何想法,为什么这可能是,或者如果我只是不知道一些相关的语法限制,请让我知道!非常感谢!Laravel - 某些输入选项不显示

HTML:

{{ Form::select('shelf', 
    array(
     '' => 'Shelf', 
     '6' => 'SPF 1 x 6 x 6', 
     '8' => 'SPF 1 x 2 x 8', 
     '8' => 'SPF 1 x 4 x 8', 
     '1' => 'WRC 1 x 4 x 8 #1', 
     '2' => 'WRC 1 x 4 x 8 #2', 
     '1' => 'WRC 1 x 6 x 8 #1', 
     '2' => 'WRC 1 x 6 x 8 #2', 
     '8' => 'WRC 1 x 2 x 8', 
     '8' => 'WRC 2 x 2 x 8',  
    ), null, 
    array('class' => 'shelf', 'id' => null)) 
}} 

到目前为止, “货架” 显示在选择为标准选择,但点击了唯一的其他选择,当是SPF 1x6x6,WRC 2x2x8,WRC 1x6x8#1和WRC 1x6x8# 2的顺序。任何和所有的帮助和指针,将不胜感激!非常感谢!

回答

1

你有这样的:

array(
    '' => 'Shelf', // --> unique 
    '6' => 'SPF 1 x 6 x 6', // --> unique 
    '8' => 'SPF 1 x 2 x 8', // --> Not unique/8 
    '8' => 'SPF 1 x 4 x 8', // --> Not unique/8 
    '1' => 'WRC 1 x 4 x 8 #1', // --> Not unique/1 
    '2' => 'WRC 1 x 4 x 8 #2', // --> Not unique/2 
    '1' => 'WRC 1 x 6 x 8 #1', // Not unique/1 (This will replace all previous 1) 
    '2' => 'WRC 1 x 6 x 8 #2', // --> Not unique/1 (This will replace all previous 2) 
    '8' => 'WRC 1 x 2 x 8', --> Not unique/8, 
    '8' => 'WRC 2 x 2 x 8', --> Not unique/8, (This will replace all previous 8) 
) 

这是因为你的array包含重复键和第一密钥是由过去的重复键所取代,这意味着,如果你有两个'2'那么第二'2'将取代第一个'2',使用独特的array keys/option value。否则你会得到这个:

<select class="shelf" name="shelf"> 
    <option value="" selected="selected">Shelf</option> 
    <option value="6">SPF 1 x 6 x 6</option> 
    <option value="8">WRC 2 x 2 x 8</option> 
    <option value="1">WRC 1 x 6 x 8 #1</option> 
    <option value="2">WRC 1 x 6 x 8 #2</option> 
</select>