Hey Joel,
This is a little confusing at times, I know ... You could think about it in the following way: The form builder (and consequently ad_form) has two modes; "edit" and "display". The script has two modes or blocks; "new" and ... well "not new". The "new" block always renders the form in edit mode but the "not new" block renders the form in either edit or display mode.
What the code does first is it determines if a new element should be added or if one already exists (the if/else clause above ad_form). What decides this is whether the element_id query var is provided or not in the request. If the script enters the "new" mode - remember that this is not a form builder mode - the form will go into edit mode. This is the default and would've been used even if I hadn't explicitly told ad_form to use the edit mode.
Now, if in the page request you provide an element_id, and the page is not in "new" mode but in the other mode which I haven't named yet 😊, the form will go into either edit mode or display mode depending on what you tell ad_form. If you don't tell ad_form anything it will default to edit mode (and an editable form will be rendered). But since there is a -mode switch to ad_form you may instruct the form to enter display mode if you so desire (and the form will be rendered read-only).
When the form is rendered in display mode (read-only) an "Edit" button appears below the displayed data (unless the -has_edit switch is being used) and, if pressed, the behavior of form builder is to _force_ itself into edit mode so that you may edit your data.
In case you want to provide a way to choose whether to render the form (for an existing element) read-only or not (the two links example you gave) you can do so by accepting a separate (optional) query var which you could call "mode" or "read_only_p" (say), and let the presence (or absence) of that var have an influence on the $form_mode var in the "not new" block of the script.
(In the element-ave.tcl script I apparently defined the "mode" var for a similar purpose, but as far as I can see it's never used anywhere in my script ...)
Does this make it clearer or dimmer? 😉
/Ola