Rendering Formulaires

Hello All,
I’ve repeatedly come across an issue. I’m sharing my workaround, but would also like to understand what could be the underlying issue.

I have a custom form. Normally I expect that I can add it to any modele, inclure or squelette as follows:

<div class="ajax">
#FORMULAIRE_CUSTOM{#ID_CUSTOM}
</div>

However, when I do that, I see in the source of the website (public), the following HTML generated:

<div class="ajax"><!--?php
include_once("./" . _DIR_RACINE . "ecrire/balise/formulaire_.php");
if ($lang_select = "de") $lang_select = lang_select($lang_select);
inserer_balise_dynamique(balise_FORMULAIRE__dyn('FORMULAIRE_CUSTOM', '466'), array('plugins/custom/squelettes/modeles/custom.html', 'html_8d5b50854283f7d3a44fc620', '_anon_L1_b12xxx0a', 9, 'de'));
if ($lang_select) lang_select();
?--></div>

By reading the SPIP source, I was able to solve the issue, by instead of calling #FORMULAIRE…, I am using PHP to render out the form. This works without error. Here’s the example that works:

<div class="ajax">
<?php
include_spip('balise/formulaire_');
echo inserer_balise_dynamique(balise_FORMULAIRE__dyn('FORMULAIRE_CUSTOM', "#ID_CUSTOM"), array());
?>
</div>		

Why would the original #FORMULAIRE… tag not work?
For the record, I am using , throughout the templates, as it has been pointed out that #MODELE should not be used in the squelettes. We are here maybe 2 or 3 levels deep into s.

Kind regards & thank you,
Urs

You don’t need to make a modele to call your form in a text since SPIP is already providing a modele for that see modeles/formulaire.html · 2.x · spip / prive · GitLab

For example, contact libre plugin use it Formulaire de contact libre - SPIP-Contrib

Hello @b_b

I am in a squelette. This issue happens when I am in a squelette where I can use #TAGS and <?php. Only the PHP approach via inserer_balise_dynamique() seems to work.
In other files, calling #FORMUALIRES works. I haven’t been able to understand why.

If I remember, models are always compiled like a « static inclusion tag », this means models are always like an #INCLURE{} or #MODELE{} and not like an <INCLURE{}>. That’s why dynamic tags (#FORMULAIRE_XXXX but also all other dynamic tags) must be treated in a particular way.

You can directly use the model modeles/formulaire and re-include it in your code, or you can copy its code and use it inside your own model if you think it’s better to mix other content around the call of the form.