Announcement

Collapse
No announcement yet.

Limiting the date selection

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Limiting the date selection

    Hello there,
    I want to choose a day for the date field only in the month we are in. Is this possible? It will give an error when choosing next or past month ...

  • #2
    I solved this problem using Hooks myself.

    Comment


    • #3
      Please share the solution if it possible. Thank you.

      Comment


      • #4
        Hi,
        I used a pretty simple method

        I first created the application / Espo / Hooks / Volvox / datecontrol.php file.

        Then I simply used the code below. and worked

        PHP Code:
        <?php

        namespace Espo\Hooks\Volvox;

        use 
        Espo\ORM\Entity;
        use 
        \Espo\Core\Exceptions\Error;

        class 
        datecontrol extends \Espo\Core\Hooks\Base
        {
        public function 
        beforeSave(Entity $entity, array $options = array())
        {

        if (
        $entity->isNew()) {
        $belgetarihi=$entity->get('belgeTarihi');
        $kayittarihi=$entity->get('kayittarihi');
        $monthb date("m",strtotime($belgetarihi));
        $monthk date("m",strtotime($kayittarihi));

        if(
        $monthb!=$monthk) {
        throw new 
        \Exception("wrong month!");


        }
        }
        }
        }

        Comment


        • telecastg
          telecastg commented
          Editing a comment
          Thanks for sharing !

        • esforim
          esforim commented
          Editing a comment
          Not simple at all! I wouldn't figure this without your post. Thank you.

      • #5
        belgeTarihi and kayittarihi is the field name right?

        Comment


        • eymen-elkum
          eymen-elkum commented
          Editing a comment
          I think yes they are the fields names,
          belgeTarihi = Document Date
          Kayittarihi = Record Date
          Translated from Turkish, hope I translated correctly

        • esforim
          esforim commented
          Editing a comment
          Tried to Like my own post to like you but it won't let me.
      Working...
      X