Document created by web form

Hello everyone,

I want to use the web form tool to create a document in the system when the form is being saved. That part is working fine, but I am asking myself whether I can have different field types in the form and in the document.

I want to add check boxes to the web form that will then be stored in a child table when the form is saved/the document is created.

Any idea on how to do this?

Thanks in advance

any one a good idea on how to set it up?
I don’t want to add multiple checkbox fields to the custom doctype just to show them in the web form and then store them in a child table within the custom doctype anyways

Hi @RSA

I have had precisely the same problem about 2 years ago. These are my notes from then. I trust they’ll help.

WebForm fields have their own independent FieldType, Label, Options, Mandatory, Hidden, Depends On, Description, Default, etc settings.
However, should you edit the fieldtype on the DocType, then the fieldtype on the WebForm is not synchronised.
You have to manually ensure the fieldtypes are compatible, eg DocType Small Text and WebForm Data but not vise versa.
Also note that Select options are carried over but not kept in synch.
Descriptions are not carried over.

You can add a field without referring to an existing counterpart on the DocType eg a page/section/column break, or a HTML/Readonly, etc all of which does not require a unique data-fieldname but to make use of a surrogate input and then transfer the value to eg a Data fieldtype you need a unique data-fieldname so that you can reference it’s web_form.on event and reference it uniquely with web_form.get_field etc.
And because you cannot assign a data-fieldname without it being part of the underlying DocType you have to define the surrogate on the DocType also.
Even though the primary field is marked as Hidden and have a class of hide-control, it is still reachable with JS code, so you cannot simply duplicate the data-fieldname on multiple Web Form fields.

2 Likes

Well thanks! That’s what I figured. I tried my luck by adding a HTML field in the web form along with the necessary check boxes and a corresponding client script setting the values in the child table - but that did not work either. I will now proceed by duplicating the doctype in question and adding a serverside function to populate the actual document by using the information from the duplicated doctype with the checkboxes added.