Wappler Version : 4.0.1
Operating System : Windows 10 x64
Server Model: NodeJS
Database Type: PostgreSQL
Hosting Type: Docker
Hello,
I have two date pickers within one form: date created - date valid. I have a pretty much basic scenario: when changing date created value and new value date is after date valid - set valid date value + 2 days of current selected date created value .
Problem is that it adds 2 days only when date different is more then 2 days. I've even got checking string which check condition if
form_edit_quotation.edit_quotation_created_date.value > form_edit_quotation.edit_quotation_valid_until.value
is true or false and even it's true - value won't change, only when 2 days difference.
Data binding code:
form_edit_quotation.edit_quotation_created_date.value > form_edit_quotation.edit_quotation_valid_until.value ? form_edit_quotation.edit_quotation_created_date.value.addDays(2) : form_edit_quotation.edit_quotation_valid_until.value
I've tried both scenarios: on value change and on date picker apply. Both has same scenario.
I’ve checked many scenarios and to be honest I can’t even follow the logic how value difference is checked and applied:
Teodor
September 1, 2021, 9:57am
3
On apply event is only available for date range picker, where you select the range and click the apply button.
@Teodor As I’ve mentioned I’ve tried both scenarios and on Apply and on Value change behavior. Both works same weird way.
Currently I have on-change:
<input class="form-control style8 read_only" id="edit_quotation_created_date" aria-describedby="basic-addon3" dmx-bind:value="sc_get_quotation_info.data.query_get_quotation_id.quotation_creation_date" dmx-bind:disabled="cookies1.data.selected_quotation != cookies1.data.edit_quotation" name="edit_quotation_created_date" required="" type="text" is="dmx-date-picker" format="DD MMM YYYY" dmx-on:changed="form_edit_quotation.edit_quotation_valid_until.setValue(form_edit_quotation.edit_quotation_created_date.value > form_edit_quotation.edit_quotation_valid_until.value ? form_edit_quotation.edit_quotation_created_date.value.addDays(2) : form_edit_quotation.edit_quotation_valid_until.value)">
Teodor
September 1, 2021, 10:17am
5
I am not sure I understand anything from your first post. Can you please explain your issue a little more clear?
@Teodor I have on Value change event for one data picker:
date1.value > date2.value ? date1.value.addDays(2) : date2.value
date1.value.addDays(2) won't work when condition is true.
<div class="col">
<input id="date1" name="date1" is="dmx-date-picker" dmx-on:changed="date2.setValue(date1.value > date2.value ? date1.value.addDays(2) : date2.value)">
<input id="date2" name="date2" is="dmx-date-picker">
</div>
Teodor
September 1, 2021, 10:48am
7
What exactly are you trying to achieve?
@Teodor When value in date1 is changed and if it’s greater than date2 value (date is date1 is later than in date2) - change date2 value for date1 value + 2 days, otherwise keep date2 value.
Teodor
September 1, 2021, 1:53pm
9
And why not just set the min date of calendar 2 to be 2 days after the value selected in calendar 1?
anyway the correct expression is:
<input id="date1" name="date1" is="dmx-date-picker" dmx-on:updated="date2.setValue(value > date2.value ? value.addDays(2) : date2.value)">
@Teodor why your expression won’t work on dmx-on:changed? Because of this: How are changed and updated different ?