Can the math hook be used with the Login - Register snippet?

I have included the hook as follows:

[[!Register? &hooks=`math`]]

I have added the following code to my register/signup form:

<label for="math">[[!+fi.op1]] [[!+fi.operator]] [[!+fi.op2]]?
  [[!+fi.error.math:notempty=`<span class="form-error-msg"><i class="fa-solid fa-circle-exclamation"></i> [[!+fi.error.math]]</span>`]]</label>

<input class="form-input" type="text" id="math" name="math" value="[[!+fi.math]]" required>

On the front end, all that shows is a ‘?’ as the field label, with a blank input field under it.

Mate, Math should be an snippet, just check what it needs to work it should work I think.
Are you adding the necessary fields it needs to work on Formit?


I’m using the register snippet. I need it to work with this snippet, not formit. I can’t find any documentation anywhere on how to use the math hook with the register snippet. I posted the code that I tried above.

The property is called preHooks in the Register snippet


For the code in the form, you should be able to use the same code as in a FormIt form. See here:

Then change [[!+fi. to [[!+reg. if you have reg. as the placeholder prefix → &placeholderPrefix=`reg.`

I’ve tried this as well and am getting the same result. On the front end, all that shows is a ‘?’ as the field label, with a blank input field under it still

I tested it using the Register example form from the documentation.

I added the math preHooks property to the snippet tag


and this code to the form:

<label>[[!+reg.op1]] [[!+reg.operator]] [[!+reg.op2]]?</label>
<input type="text" name="math" value="[[!+reg.math]]" />
<input type="hidden" name="op1" value="[[!+reg.op1]]" />
<input type="hidden" name="op2" value="[[!+reg.op2]]" />
<input type="hidden" name="operator" value="[[!+reg.operator]]" />

This works on my system (MODX 3.0.3 and Login 1.9.12-pl).

I didn’t have the ‘H’ in ‘preHooks’ capitalized! I believe that’s why it wasn’t working, than you!

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.