Differents format dates for input hidden and input date

Differents format dates for input hidden and input date

klermannklermann Posts: 277Questions: 67Answers: 1

Hi, Allan. How can I capture the date in a hidden field, but capture the full date, since at the current time I am capturing only in the format yyyy-mm-dd, but need to capture in the format yyyy-mm-dd HH: mm: ss without changing the original field, ie in the hidden field capture the full date and in the original field continue with the same format?

Answers

  • allanallan Posts: 61,715Questions: 1Answers: 10,106 Site admin

    You would probably need to use dependent(). Have that triggered on the field the user can change the value of and then when the change happens update the hidden field, splicing in the date part (e.g. split on the space character and join the required parts together).

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    My fields:

     {
                          name: "adicDiaAnterior",
                          type: "hidden"
                     },
                     {
                          name: "dataAcesso",
                          type: "datetime",
                             opts: {
                                minDate: new Date('2000-01-01'),
                                maxDate: new Date('2050-12-31'),
                                format: 'DD/MM/YYYY',
                                locale : 'pt-BR',
                                showTodayButton : true,
                                showClear : true
                          }
                     }
    

    My json edited with the field dataAcesso:

    {"iTotalRecords":3,"iTotalDisplayRecords":3,"data":[{"dataAcesso":{"dayOfMonth":4,"dayOfWeek":"MONDAY","month":"JUNE","year":2018,"dayOfYear":155,"monthValue":6,"hour":19,"minute":1,"nano":0,"second":47}]}
    

    It is the i need:
    In the field hidden the date full, with the format yyyy-mm-dd HH: mm: ss, and in the field dataAcesso o formato yyyy-mm-dd

  • klermannklermann Posts: 277Questions: 67Answers: 1

    Allan. I did not understand your suggestion, can you repeat with more clarity, please, how can I assign the full date of a field that does not pick up that full date?

  • allanallan Posts: 61,715Questions: 1Answers: 10,106 Site admin

    I don't actually see yyyy-mm-dd in your data - I see the individual values for each component. Do you want to edit them in a single field? You need to use a get and set formatter if you want to combine multiple database values into one field (I assume that you have each value stored separately in the database).

    Allan

  • klermannklermann Posts: 277Questions: 67Answers: 1

    Solved here in backend, thanks Allan!

This discussion has been closed.