·
Added a discussion

Hi All,

Just created some custom fields on profile, set them as Unique but not mandatory, adding new profile - I see these fields, entering nothing in them, submitting the form, getting error 'The field should have unique value'.
Seems like it interpreted existing empty values in database as a value and can't create empty value since it will be the same.
Seems like a bug.

  • 2962
Comments
    • Hello boonexpert !

      As you know from our discussion in Messenger, I don't consider that this is a bug. Because the empty value is the value too. And could be used by 1 user :-) If this is not OK then you need to add the Mandatory check for non-empty value too.

      • Hello boonexpert !

        As you know from our discussion in Messenger, I don't consider that this is a bug. Because the empty value is the value too. And could be used by 1 user :-) If this is not OK then you need to add the Mandatory check for non-empty value too.

        Are you really being serious saying this? :)

        So then “mandatory” field doesn’t make any sense since there always will be empty values in the db and user will be forced to enter any value into the field.
        The field should accept empty values when “mandatory” is off. No matter what’s in the db. I work with web for the past 16+ years and It’s a simple logic.

        • Are you really being serious saying this? :) 

          Absolutely.

          I work with web for the past 16+ years and It’s a simple logic.

          Wow, definitely the time period of my work in Boonex for now!

          • I work with web for the past 16+ years and It’s a simple logic.

            Wow, definitely the time period of my work in Boonex for now!

            You being so lordly. Great support from such an arrogant staff. Thanks.

            So you compare the empty form field - nothing to nothing - thinking of "nothing" as of data. Cool.

            So the field cannot be left empty, no matter if "mandatory" is off. So "mandatory" flag doesn't make any sense if I want to leave it empty. I never can leave the field empty. So it's "mandatory" in each case.

            I have no more words to say.

            • Sorry, didn't have any intentions of being "arrogant". Regarding our problem - if in the MySQL table you will make some field as UNIQUE and then add 1 record without filling this field then you can't add other records by this way (not value for this field) too.

              • Right.

                The website is not just clear MySQL, it has some logic written in PHP. Which should check if "mandatory" is off, "unique" is on, then if field is empty or not, also by trimming spaces - and if it's empty - to not do anything. If not empty - then check if entered value is unique by db table.

                If I want users to be able to leave the field empty, I should uncheck "mandatory". 

                If I want them to fill it with any data, I should check the "mandatory".

                Simple. It works like this on all platforms.

                • image_transcoder.php?o=bx_froala_image&h=5087&dpx=2&t=1620597088

                  image_transcoder.php?o=bx_froala_image&h=5088&dpx=2&t=1620597134

                  INSERT INTO `test` (`id`, `value`) VALUES (NULL, NULL);

                  1 row inserted.

                  INSERT INTO `test` (`id`, `value`) VALUES (NULL, '123')

                  #1062 - Duplicate entry '123' for key 'value'

                  Even in clear MySQL. Unique. No problem.

                  • Yes, the website isn't just MySQL and the field has the type like varchar and not NULL values. So empty input will look like VALUES (NULL, ''); and in this case, you can't insert 2 similar records.

                    • Yes, the website isn't just MySQL and the field has the type like varchar and not NULL values. So empty input will look like VALUES (NULL, ''); and in this case, you can't insert 2 similar records.

                      That’s exactly what I mean. If set to Unique and not mandatory, it must be Null.

                      Login or Join to comment.