You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2022-10-26 13:23:49

WebGreg
Member
Registered: 2020-02-27
Posts: 729

Formcreator - how to set the visibility option

Hi

Field1 - type date
Field2 - hidden unless Field1 .... ?

How to check if the field has been completed?


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#2 2022-10-26 13:29:24

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: Formcreator - how to set the visibility option

Hi

There is no comparison operator to test if a field has been filled or not. I think you may workaround by using the regex operator. Someting like /.+/ which means that there is at least 1 character.


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#3 2022-10-26 14:47:06

WebGreg
Member
Registered: 2020-02-27
Posts: 729

Re: Formcreator - how to set the visibility option

Thank You @btry.

I don't know regex, but I've tried with:
/^[0-9]{4}-[0-9]{2}-[0-9]{2}.$/i

Unfortunately it does not work. It did not work with your proposal either sad 


There are a lot of mathematical operators and they are not work predictable for me. Most often I use the "if the field is not empty" option. It is a pity that there is no such thing - just "not empty". At the moment, sometimes it works for me with =/=, sometimes with >, sometimes not at all smile


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#4 2022-10-26 15:02:38

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: Formcreator - how to set the visibility option

I did a quick check : regex is not implemented for date / datetime questions. This is why the regexes don't work.

I see in the code that a empty value is replaced with zeros before the comparison. Then you may try to detect an empty date bay comparing it against 0000-00-00. A dateteime should be compared against 0000-00-00 00:00:00.


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#5 2022-10-26 16:34:53

WebGreg
Member
Registered: 2020-02-27
Posts: 729

Re: Formcreator - how to set the visibility option

OK thank you for the information.

It would be nice if there was a legible description somewhere what does not work with something. I spent some time testing different expressions :-D Because if an option is available, it probably works wink

Regards!


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#6 2022-11-04 22:43:19

WebGreg
Member
Registered: 2020-02-27
Posts: 729

Re: Formcreator - how to set the visibility option

Hi @btry

Tried with:
= 0000-00-00
=/= 0000-00-00

Unfortunately it doesn't work either.


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#7 2022-11-05 11:41:00

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: Formcreator - how to set the visibility option

Hi

I checked and found the problem.

Apply this patch and it should work fine: https://github.com/pluginsGLPI/formcrea … 7b3a0a9517


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#8 2022-11-05 14:48:00

WebGreg
Member
Registered: 2020-02-27
Posts: 729

Re: Formcreator - how to set the visibility option

Hi btry

I had to clear my browser cache and it works with "=/= 0000-00-00". Thank You smile


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#9 2022-11-09 15:37:23

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: Formcreator - how to set the visibility option

Hi

I found the problem. This commit should solve it, and allow the comparison with 0000-00-00

https://github.com/pluginsGLPI/formcrea … 7b3a0a9517


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

Board footer

Powered by FluxBB