Here's the form itself — the input fields, the validation, the layout.
This is the input block itself — the fields, the validation, the footer buttons. Trimmed to the fields that matter:
<Block tag='div'> <Element type='form'> <Form id='addcontactform' Name='ADDCONTACT' Method="POST" enctype="multipart/form-data" OnSubmit='validate_form()'> <Action><![CDATA[javascript:setupaddcontactform()]]></Action> <HiddenFields> <Input type='hidden' name='submod' value='insertcontact' /> </HiddenFields> <Valscript>emxml_Scrdefault.xml</Valscript> <FormPanel type='Singlepage'/> </Form> <Element type='inlinecontainer' tag='div'> <Attributes class='modal-body' /> <Element type='formtables'> <n>ft1</n> <FormPage>ft1</FormPage> <Table id='ft1' class='table'> <Row><Col> <Element type='htmlforminput' tag='input'> <Attributes id='contact_name' name='contact_name' placeholder='Full name' /> <Validation><Validate type="mandatory" tmplt="tmp1">Name is required</Validate></Validation> </Element> </Col></Row> <Row><Col> <Element type='htmlforminput' tag='input'> <Attributes id='email' name='email' placeholder='Email address' /> <Validation><Validate type="mandatory" tmplt="tmp1">Email is required</Validate></Validation> </Element> </Col></Row> <!-- department, job_title, phone follow the same pattern --> </Table> </Element> </Element> <!-- Footer inside <Element type='form'> so validation/submit stay wired --> <Element type='inlinecontainer' tag='div'> <Attributes class='modal-footer' /> <Element type='htmlitem' tag='button'> <Attributes type='button' class='btn-ghost' onclick="bcModal.close('bcmodaloverlay')" /> <Text>Cancel</Text> </Element> <Element type='htmlitem' tag='button'> <Attributes type='submit' class='btn-primary' /> <Text>Save Contact</Text> </Element> </Element> </Element> </Block>
<Block tag='div'>, with <Element type='form'> nested inside — same rule as every other block file in this arc.OnSubmit='validate_form()' automatically. Adding an onclick here would either skip validation or fire the submit twice — the Cancel button is the only one that needs a manual onclick, because it just closes the modal.Updating one is different — the form needs to display the current record before anything can be changed. That's where a form's own SQL block comes in, and the same applies to any form that needs to show existing data, not just this one.
<Block tag='div'> <Element type='form'> <Form id='editcontactform' Name='EDITCONTACT' Method="POST" enctype="multipart/form-data" OnSubmit='validate_form()'> <Action><![CDATA[javascript:setupeditcontactform()]]></Action> <HiddenFields> <Input type='hidden' name='submod' value='updatecontact' /> <Input type='hidden' name='contact_id' value='%contact_id%' /> </HiddenFields> <Valscript>emxml_Scrdefault.xml</Valscript> <FormPanel type='Singlepage'/> </Form> <Element type='inlinecontainer' tag='div'> <Attributes class='modal-body' /> <Element type='formtables'> <n>ft1</n> <FormPage>ft1</FormPage> <Table id='ft1' class='table'> <Row><Col> <Element type='htmlforminput' tag='input'> <Attributes id='contact_name' name='contact_name' value='%contact_name%' /> <Validation><Validate type="mandatory" tmplt="tmp1">Name is required</Validate></Validation> </Element> </Col></Row> <Row><Col> <Element type='htmlforminput' tag='input'> <Attributes id='email' name='email' value='%email%' /> <Validation><Validate type="mandatory" tmplt="tmp1">Email is required</Validate></Validation> </Element> </Col></Row> <!-- department, phone follow the same pattern, each pre-filled with its own %token% --> </Table> </Element> </Element> <Element type='inlinecontainer' tag='div'> <Attributes class='modal-footer' /> <Element type='htmlitem' tag='button'> <Attributes type='button' class='btn-ghost' onclick="bcModal.close('bcmodaloverlay')" /> <Text>Cancel</Text> </Element> <Element type='htmlitem' tag='button'> <Attributes type='submit' class='btn-primary' /> <Text>Save Changes</Text> </Element> </Element> </Element> <!-- runs once, before the form renders, so every field opens pre-filled --> <SQL> <query name='contact_prefill'> <![CDATA[ SELECT contact_name, email, department, phone FROM contacts WHERE contact_id = '%contact_id%' AND dept_id = '%deptid%' LIMIT 1 ]]> </query> </SQL> </Block>