Weird on-apply/changed behavior

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:

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)">

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>

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.

And why not just set the min date of calendar 2 to be 2 days after the value selected in calendar 1?

Screenshot 2021-09-01 at 16.55.41

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)">

Many thanks @Teodor

@Teodor why your expression won’t work on dmx-on:changed? Because of this: How are changed and updated different?