populating text_input with date from calendar selection

I have tried so many variations. Basically, we want to validate event dates from sentences. We have publication date, and I am using extracted dates if we find one, but sometimes sentences would refer to "last Friday". So I am using a block like this:

    blocks = [{"view_id": "spans_manual"},
              {"view_id": "choice"},
              {"view_id": "text_input",
               "field_rows": 1,
               "field_label": "Event Date",
               "field_id": "event_date"}

And custom html with an "Apply" button to signal copying the value.

<button type="button" id="apply"

I have tried setting the value and also textContent of event_date, but none of these seem to work and save the data in prodigy, although it does update the browser window with the value. If I type in the event_date text window, then it saves the data. But prodigy does not seem to recognize there is updated text in the field when it is populated with the copy assignment statements. I also tried javascript, but I can't get it to recognize the method call.

Any suggestions??

Hi there!

Could you share a screenshot of your interface? It's a bit unclear to me if an event date is mainly a label in the spans_manual interface or if it is a label from the choice interface.

Just to be clear, this would copy the value from the cal_date element? Is that an element in the spans_manual element? I'm partially asking because I'm wondering what needs to happen in the front-end and if your intended action is perhaps better handled on the Python side of things using the before_db callback.

This is the current view.

event_date is the field_id of the text_input
cal_date is the id of the calendar object

I was using the text_input to get the value back into the annotation for the calendar date selection.
The id values for all the choices are below and there is no overlap of id values.
{"id": "pubdate", "text": ":white_check_mark: use publication date"},
{"id": "exdate", "text": ":white_check_mark: use extracted date"},
{"id": "moddate", "text": ":white_check_mark: use selected calendar date"}

The text_input (event_date) works if I type into the field but does not work if I assign it a value from the calendar object. Maybe I don't have the assignment correct to trigger that the field changed but the browser view does get updated.

I don't think i can use the before_db on the python side, because i need to get the value from the browser into the annotation.

Any suggestions??

Is the calendar rendered with custom html? You blocks definition earlier suggests that you're not using a custom html block. But I guess it might be rendered as part of the choice view.

I worry that the html block itself is not aware of the textfield. It feels like it might get fixed by adding custom javascript via the config. This might have access to the entire doc.

Is it possible for you to send a minimal viable example my way? Maybe the custom recipe code together with a few examples? It might be easier for me to debug/understand this with the example in front of me.

FYI: I solved the problem by removing the text_input and adding the annotation to the task in the
document.addEventListener('prodigyupdate', event =>

It seemed like it should be the prodigyaccept but I could not get that to work.

1 Like