0
In a maintainability and organization perspective what should contain a value attribute? a number representing a word:
<label><input type="radio" name="order" value="1">Masculino</label>
<label><input type="radio" name="order" value="2">Feminino</label>
<label><input type="radio" name="loja" value="1">Ricardo Eletro</label>
<label><input type="radio" name="loja" value="2">Submarino</label>
<label><input type="radio" name="loja" value="3">Casas Bahia</label>
or content ready to be entered/searched in the database for example:
<label><input type="radio" name="order" value="Masculino">Masculino</label>
<label><input type="radio" name="order" value="Feminino">Feminino</label>
<option value="MaisCaroPrimeiro">Mais caro Primeiro</option>
<label><input type="radio" name="loja" value="RicardoEletro">Ricardo Eletro</label>
<label><input type="radio" name="loja" value="Submarino">Submarino</label>
<label><input type="radio" name="loja" value="CasasBahia">Casas Bahia</label>
When and where to convert to the actual value?
Guy, based on opinions, ie, depends a lot on the taste of the person. I prefer the code, (1,2,3...) in the case of sex, may be used (f, m)...
– KaduAmaral
What do you put in
value
is what will be sent to the server. In the case of a radio button - where the end user does not see the attribute value - the simplest is to put the data which will be easier to be handled by the server. (always remembering to validate the die before using it)– mgibsonbr
I edited with one more example
– Ricardo
Placing a value that is within the scope of
input
will always be the best approach, it is much easier you identify what is aselect
worthwhilem
ormale
than one with value1
. You do not need to write the "full" value, but enough so you do not generate more complexity in your code, but all this is my opinion only, good practices, etc.– Eduardo Silva
I voted to reopen. In my opinion, this question could not be treated specifically as "based on opinions". If you are declaring that you have a "search" method that has as Feature "sort records the way you want" the highest level would be that you have readable values. The reason these values are readable, is that imagine you were going to make your method available over a web service for example, which is more readable for your business layer ? something that represents your business (ordernar_por_idade_asc) or by column names (ASC age) ?
– wryel
@wryel I understand your explanation.
– Ricardo
As they say, it all depends on the modeling of your data and what you do with it. Do not want to [Dit] the question and add information on that part?
– bfavaretto