We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51074
    • 14 Posts
    There is a table(migxdb) with a date field ("inputTVtype":"date"). When I choose date in a database value perfectly remains. But when I erase date (I delete value), changes nothing. In the table again date! How to save empty value of date?
    Version 2.9.7
      • 4172
      • 5,888 Posts
      seems you are right and the datepicker sends the last value, if trying to save an empty value.
      Real Date-TVs seem to accept empty values, strange.

      A workarround could be a checkbox-TV 'empty date' and aftersave-hook-snippet, which empties the date, when that checkbox was checked.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 51074
        • 14 Posts
        Quote from: Bruno17 at Jan 30, 2016, 01:11 PM
        seems you are right and the datepicker sends the last value, if trying to save an empty value.
        Real Date-TVs seem to accept empty values, strange.

        A workarround could be a checkbox-TV 'empty date' and aftersave-hook-snippet, which empties the date, when that checkbox was checked.
        Thanks for the help. But checkbox-TV isn't really beautiful the decision for a user. I tried to use the "inputTV":"mydate" but too most doesn't save empty value. It is necessary to look for other decision.
          • 4172
          • 5,888 Posts
          I think, found the reason.
          A datetime-field deosn't let you save an empty string.
          You can save 0000-00-00 00:00:00, but not an empty string.

          Try to change your field into a text-field. Than you can save an empty string to that field.

          Or make the phptype 'string'

          <field key="date" dbtype="datetime" phptype="string" null="true" />


          this will store an empty string as 0000-00-00 00:00:00 [ed. note: Bruno17 last edited this post 10 years, 8 months ago.]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 51074
            • 14 Posts
            Quote from: Bruno17 at Jan 31, 2016, 12:47 AM

            Try to change your field into a text-field. Than you can save an empty string to that field.

            Or make the phptype 'string'

            <field key="date" dbtype="datetime" phptype="string" null="true">


            this will store an empty string as 0000-00-00 00:00:00</field>

            Right! Excellent decision! Thank you very much.