Duplicating a date field

Status
Not open for further replies.

BasilC

Member
Developing J4 version of a J3 website on XAMPP.
J4.2.8
Fabrik 4gamma2
PHP8.1

On J3 I have an events database with a field for the starting date and a field for the end date, both using the old date element.

Most events are on a single day, so very conveniently after selecting a date in the eventdate field, when I click in the eventenddate field, the value is copied over from eventdate.

I can't remember how I set this up and can't see anything in the settings for the two elements that would make this happen. It's a mystery.

On J4 this doesn't happen, eventenddate stays empty when I click in it and I have to use the date picker to select a value.

So as an alternative approach I tried setting a default for the eventenddate field.



Snap6.png


However, this setting causes an error when I go to open the list

Snap7.png



I have couple of validations, notempty and isgreaterorlessthan

Snap8.png


Any idea why clicking in the field works in J3 but not J4?

Any idea what is causing this error or what the optimum solution is for pre-populating the eventenddate field?
 
when I click in the eventenddate field, the value is copied over from eventdate.
I assume you have a JS action set up in your element (or in some form_X.js file). Didn't it take it over to J!4? Maybe it's there but you have to adapt.

The error:
Obviously you can't use other element placeholders in default, thery are not set on new records, so not replaced (it's the same in F3). You can use placeholders like {year} or {$my->id}.

Setting a default is useless in this case anyway, defaults are only run while loading a new record.
 
Thanks, exactly right. I didn't think about JS because I know absolutely nothing about it. I must have copied it from somewhere, or perhaps got it from someone on this forum (you perhaps)

The code is

Code:
$('tbl_events___eventenddate_cal').value = $('tbl_events___eventdate_cal').getValue();

but it clearly isn't working. I tried changing Focus to Click, but that didn't work.
 
This was working?

Something like
jQuery('#tbl_events___eventenddate_cal').val(jQuery('#tbl_events___eventdate_cal).val());
(Edit: added the missing quote)
jQuery('#tbl_events___eventenddate_cal').val(jQuery('#tbl_events___eventdate_cal').val());
should do.
 
Last edited:
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top