106 Posts
krkr
11 years ago
4
Topic

Hello

Please help with conditional states for fields.

Situation: 1 checkbox field with one value "A" and 2 Date fields DateA and DateB

This is working: When A is selected then DateA and DateB is visible, when A is NOT selected then DateA and DateB is hidden.

This is what I need additional: When A is not selected and DateA and DateB is hidden, then when I save form values for DateA and DateB should be empty, zero or like for date field with value 0000-00-00 00:00:00. Also this could happen at the moment when is changed field A state (before save), doesn't matter if I will lose previous value at state changing. 

Brgds

PS. FORUM POSTING!!! If you write here anything in forum, then before submitting copy message text, because sql errors or someone posted in your post id but in different place and some more errors. Just not to lose text you wrote. 


Get a VIP membership
106 Posts
krkr
11 years ago
3
Level 1

none?

154 Posts
WebOne
11 years ago
2
Level 2

Can't you just set a DEFAULT value using MySQL ? (if you are saving blank/null data it could be used to set a default)

Eg:

ALTER TABLE xyz_cck_store_form_mytable ALTER datecol SET DEFAULT 0;

106 Posts
krkr
11 years ago
1
Level 3

Hi

Thanks for idea.

I will try it , but I afraid, that there is problem after.

For example first step: article created 1st time -> A checked, DateA saved with value, DateB by default is saved 0,

next step: later, article changed, also these fields. A unchecked, DateA is with previous value, DateB is with new value saved. But problem is that DateA should be 0 and until I will not clean it up manually, it will stay the old.

The best way is to clear value on field switching on off, so values clearing to 0, or at least with save.

And thing is to make backend usable for "smart users", so I need to avoid: "please remember to clean up this field before switching".

Brgds

154 Posts
WebOne
11 years ago
0
Level 4

Using CONDITIONAL STATES you can change the value of a field using FILLED.

ie.

Is FILLED (value)   ----- CONDITION 

So you might be able to work something out with this.

Get a VIP membership