Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source put data on other order #23

Closed
silasrm opened this issue Mar 5, 2017 · 15 comments
Closed

Source put data on other order #23

silasrm opened this issue Mar 5, 2017 · 15 comments

Comments

@silasrm
Copy link

silasrm commented Mar 5, 2017

Hi,

I've a array of options to Estado field:

array:28 [▼
  "AC" => "Acre"
  "AL" => "Alagoas"
  "AP" => "Amapá"
  "AM" => "Amazonas"
  "BA" => "Bahia"
  "CE" => "Ceara"
  "DF" => "Distrito Federal"
  "ES" => "Espirito Santo"
  "GO" => "Goiás"
  "MA" => "Maranhão"
  "MT" => "Mato Grosso"
  "MS" => "Mato Grosso do Sul"
  "MG" => "Minas Gerais"
  "PA" => "Para"
  "PB" => "Paraiba"
  "PR" => "Parana"
  "PE" => "Pernambuco"
  "PI" => "Piaui"
  "RN" => "Rio Grande do Norte"
  "RS" => "Rio Grande do Sul"
  "RJ" => "Rio de Janeiro"
  "RO" => "Rondônia"
  "RR" => "Roraima"
  "SC" => "Santa Catarina"
  "SE" => "Sergipe"
  "SP" => "São Paulo"
  "TO" => "Tocantins"
  "EX" => "Exterior"
]

And I'm set like a documentation:

$form2->source('estados', $estados);

And in html I use:

<select name="estado" id="estado">
                    <option value="">- selecione -</option>
                    <options source="estados" />
                </select>

But the form html returne with options in reverse order and with a empty in first position:

<select name="estado" id="estado" >
<option value=""></option><option selected="selected" value="">- selecione -</option>
<option value="EX">Exterior</option>
<option value="TO">Tocantins</option>
<option value="SP">São Paulo</option>
<option value="SE">Sergipe</option>
<option value="SC">Santa Catarina</option>
<option value="RR">Roraima</option>
<option value="RO">Rondônia</option>
<option value="RJ">Rio de Janeiro</option>
<option value="RS">Rio Grande do Sul</option>
<option value="RN">Rio Grande do Norte</option>
<option value="PI">Piaui</option>
<option value="PE">Pernambuco</option>
<option value="PR">Parana</option>
<option value="PB">Paraiba</option>
<option value="PA">Para</option>
<option value="MG">Minas Gerais</option>
<option value="MS">Mato Grosso do Sul</option>
<option value="MT">Mato Grosso</option>
<option value="MA">Maranhão</option>
<option value="GO">Goiás</option>
<option value="ES">Espirito Santo</option>
<option value="DF">Distrito Federal</option>
<option value="CE">Ceara</option>
<option value="BA">Bahia</option>
<option value="AM">Amazonas</option>
<option value="AP">Amapá</option>
<option value="AL">Alagoas</option>
<option value="AC">Acre</option>
</select>

Any solution?

@Gregwar
Copy link
Owner

Gregwar commented Mar 5, 2017

Hello,

This is indeed a reproductible bug

Gregwar added a commit that referenced this issue Mar 5, 2017
@Gregwar
Copy link
Owner

Gregwar commented Mar 5, 2017

Thanks for reporting
Should be fixed in master, can you confirm and close?

@silasrm
Copy link
Author

silasrm commented Mar 5, 2017

@Gregwar the order is fixed. But, the empty option in first position continues:

<select name="estado" id="estado" >
<option value=""></option>
<option selected="selected" value="">- selecione -</option>
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
...
</select>
<select name="estado" id="estado">
                   <option value="">- selecione -</option>
                   <options source="estados" />
               </select>

@Gregwar
Copy link
Owner

Gregwar commented Mar 5, 2017 via email

@Gregwar
Copy link
Owner

Gregwar commented Mar 5, 2017 via email

@silasrm
Copy link
Author

silasrm commented Mar 5, 2017

@Gregwar I understand, But I desire set the "label" of this blank option.

@silasrm
Copy link
Author

silasrm commented Mar 5, 2017

My idea

Add a attribute flag, named as without-empty-item, (won't replicated as element attributes) that says: this <select> hasn't a default empty option, without to use required attribute. But, if element is set as required, the default empty option won't added like before.

Example:

<select name="estado" id="estado" without-empty-item>
                    <option value="">- selecione -</option>
                    <options source="estados" />
                </select>

OR add attributes to set de value and label of default empty option:

Example:

<select name="estado" id="estado" empty-item-value="0" empty-item-label="- selecione -">
                    <options source="estados" />
                </select>

What do you think?

@Gregwar
Copy link
Owner

Gregwar commented Mar 6, 2017 via email

@silasrm
Copy link
Author

silasrm commented Mar 6, 2017

@Gregwar I agree with you :D

@Gregwar
Copy link
Owner

Gregwar commented Mar 6, 2017

Ok, it's done, tell me if it's OK for you

@Gregwar
Copy link
Owner

Gregwar commented Mar 6, 2017

Maybe I should make a new tag, like v1.1

@silasrm
Copy link
Author

silasrm commented Mar 6, 2017

I'm glad with that solution. Thank you so much @Gregwar.

@silasrm silasrm closed this as completed Mar 6, 2017
@silasrm
Copy link
Author

silasrm commented Mar 6, 2017

@Gregwar you will make a new release?

@Gregwar
Copy link
Owner

Gregwar commented Mar 6, 2017

I tagged master v1.1.0, so depending on * or 1.* should work now

@silasrm
Copy link
Author

silasrm commented Mar 6, 2017

Many thanks @Gregwar :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants