terminal42 / contao-conditionalformfields

Display form fields conditionally in Contao Open Source CMS
MIT License
18 stars 13 forks source link

Note on the interaction of conditional-formfields, multipage-form and ajax-form #89

Open zonky2 opened 3 months ago

zonky2 commented 3 months ago

To ensure that the conditions for previous steps work with MP_Forms, a data attribute is filled with values in the form tag.

When used with ajax-form, the form tag is not updated and therefore no current values can be read from conditional-formfields.

As a workaround, the template ajaxform_inline.html5 can be customised:

<form action="<?php echo $this->action; ?>"<?php if ($this->formId): ?>id="<?php echo $this->formId; ?>"<?php endif; ?>
      method="<?php echo $this->method; ?>"
      enctype="<?php echo $this->enctype; ?>"<?php echo $this->attributes; ?><?php echo $this->novalidate; ?>>
    <div class="formbody">
        <?php if ($this->method != 'get'): ?>
            <input type="hidden" name="FORM_SUBMIT" value="<?php echo $this->formSubmit; ?>">
            <input type="hidden" name="REQUEST_TOKEN" value="{{request_token}}">
            <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $this->maxFileSize; ?>">
        <?php endif; ?>
        <?php echo $this->hidden; ?>
        <?php echo $this->fields; ?>
    </div>
</form>

The behaviour with Contao 5 still needs to be checked.

zoglo commented 3 months ago

Wouldn't work with the insert-tag {{request_token}} as it has been removed in C5

zonky2 commented 3 months ago

I am aware of this - but this is the original template...

https://github.com/terminal42/contao-ajaxform/blob/ec26c11fb619b51dfcf2297a18a7a0a4e0a735f7/templates/ajaxform_inline.html5#L4

zoglo commented 3 months ago

Remember that ajaxform won't be used in Contao 5 anymore since it's part of the Contao Core in 5.1, thus you'd be able to use the template from the contao core 😄.

Meaning you wouldn't need to bother about that.

zonky2 commented 3 months ago

@zoglo

The behaviour with Contao 5 still needs to be checked.