Tracker - Custom form

Hi community members,

Can anyone guide me how I can place the labels (formName) for the inputs, so programRules will hide them as well as input elements?
Otherwise I can see that labels remains on the screen while the input fields are hidden by the programRules.

Thank you.

Regards,
Ulanbek

1 Like

Hi @Ulanbek

If this is so then this is a bug issue. Is this the Tracker Capture app or the Capture app? What is the version of the dhis2 instance?

I tried reproducing the issue on https://play.dhis2.org/dev-2-40 but couldn’t reproduce it. When I choose the action to hide field, the whole row is hidden including the label and input field.

Thanks!

Hi @Gassim

It seems I have explained not clearly my request:
Currently I want to create a custom form for the stage inside the tracker. Therefore I want to place a text labels (formName) into the custom form in such way, so when the data element get hided by the programRules, the data element’s label should hide as well. Additionally how I can get that label dynamically, including translation of that formName string?

Btw I have tried to place my checkbox, textarea and other data input fields and got error message and those elements have not been rendered.

Can anyone provide some example of tracker custom form with the response to the all questions above? Would be great to get also example of how jQuery could be used in connection to the existing data elements.

Thank you
Regards,
Ulanbek

Thank you for the clarification @Ulanbek! Lots of great questions, and it’s important to remember that creating a custom form comes with its own challenges compared to the standard format.

I now understand what you mean. For this I think you will need to use JavaScript in the form to check for the field when it’s visible or not. For example, knowing that the row only contains the input field, add an id to the row and then use the JavaScript to see if(document.querySelector("#testing1 > div") == null) which means it’s no longer there (has been hidden)

Looks like you’re looking into something quite complex. For this to be dynamic it will require a lot of working and will probably need to use the API. I’m not sure how’d one connect from the form to the API since this will require authentication and it’s not safe to include it in the HTML form unless it’s being called from a secure server.

Maybe there’s a workaround using the standard form?