dateTimeType got now() as default value

    • Danko
      Participant
        # 2 years, 4 months ago

        Hi,

        I have several datetime field. Everything is working perfectly but for one tiny detail.
        I don’t want the default value as now() in these fields. Maybe in some of them but not all.

        I cannot find where, this default value, apply to the form field.

        Cab u help?

        Thanks,

        Daniele.

      • laravel-bap
        Keymaster
          # 2 years, 4 months ago

          YOu mean when You click on datetime input date time is selected? If not send more details + screenshot.

        • Danko
          Participant
            # 2 years, 3 months ago

            Hi,

            actually I found that in this file
            Modules/Platform/Core/Repositories/PlatformRepository.php,
            in both update and create Entity, there were this mechanism.

            I think this was the instruction:
            $entity->setAttribute($field, $value);
            This is within a foreach, working all the entity attributes.

            Since I cannot find setAttributes function I UNSET the attributes I don’t want to be forcibly set (only if they are null in the first instance):

            I also add this code:

            I needed to have created_at and updated_at in the user timezone.

            Thank you.

          • Danko
            Participant
              # 1 year, 9 months ago

              Hi,

              I am reopening this issue because I have not solved it so far.
              the mechanism I wrote about, in Platform/Core directory, was correct. In that way I can modify a form field during the save phase.

              But, this issue was originally different.

              What I mean exactly is that when I click a dateType field in a form, a calendar open (and it’s correct) and the current date appear into the field.
              I don’t want the current date to appear into the field.

              How can I prevent that ?

              Thank you and have a nice new year 🙂

              Daniele.

            • Danko
              Participant
                # 1 year, 9 months ago

                Hi,

                I solved the issue.
                I find in Entities, regarding the field I have the issue on, this code:

                /**
                * Required to proper parse date provided in user date format
                * @param $value
                */
                public function setclosingDateAttribute($value)
                {
                $parsed = Carbon::parse($value);

                $this->attributes[‘closing_date’] = $parsed;
                }

                I got rid of the Carbon thing, setting $parsed to $value and I got what I wanted 🙂

                Do you think this would be correct ?

                Thank you for your help

                Daniele.

            Viewing 4 reply threads

            You must be logged in to reply to this topic.