have a little trouble checking for null on the front end. I have 2 date fields, these fields only get shown if a certain service is selected. So most the time are not shown and null.
the 2nd date field adds 1 month to the first date field (if the first date field is not null. but it ignores this.
The key for wrapping code is the ‘backtick’ - if you search online for the location on your keyboard you’ll probably have it. To do a block of code use 3 backticks either side
See here (you could copy and paste from this post too):
thanks. yeah my keyboard oddly doesnt have it, will have to google it and copy paste it, just needs a button on toolbar thanks for the tip, will edit my post
I suspect you might be having problems because the id of the inputs matches the name attribute. Try making it something like id="inp_StorageFrom" name="StorageFrom"
and then updating the other reference dmx-bind:value="(inp_StorageFrom.value != 'null').addMonths(1)"
Ah. You have null encapsulated as a string - try removing the speech marks and make it a ternary (otherwise you are trying to use a true/false with the addMonths):
I appreciate the help, but for me still not working, and i copy pasted your line next to my lines and compared and they are equal. I am doing a DB insert and its the DB field that has the date showing, but, the field I store to is just a text not a date field as it seems date fields cannot be null, but the text field always receives the date 1970
So is your problem that the field doesn’t show the right step on the client-side or that the wrong value is inserted into the DB?
Date fields can be null as long as the column in the table is set up to allow it, but you might also want to make the insert value {{$_POST.StorageTo.default(null)}}
An empty string will use null instead of the epoch date