1

I try to learn MODX FormIt component usage (MODX revolution v.2.7.0, FormIt v. 4.1.1). Now I try to set validation rules for form field, such as "required, only numbers, greater than", meanwhile I want to use placeholder for minimal value. I call FormIt like this:

[[!FormIt?  
  &hooks=`openSession`
  &redirectTo=`1`
  &placeholderPrefix=``
  &validate=`my_field:required:isNumber:minValue=`[[!+my_min_value]]``
]]

but I can input any number in 'my_field' field. If I use number for minValue instead of placeholder, all works fine. Placeholder is successfully resolving into number in the form below, too. When I am wrong?

VlLight
  • 53
  • 4

1 Answers1

0

IIRC, you cannot use placeholders in the parameters.

Although, you should try with the following code, in case it is now supported in latest versions:

[[!FormIt?  
  &hooks=`openSession`
  &redirectTo=`1`
  &placeholderPrefix=``
  &validate=`my_field:required:isNumber:minValue=^[[!+my_min_value]]^`
]]

OR

You could use custom validator, in which you should be able to use getPlaceholder to read your placeholder.

For more details on why use ^ instead of back-ticks, please see https://docs.modx.com/extras/revo/formit/formit.validators

Zaigham R.
  • 612
  • 1
  • 6
  • 12
  • Unfortunately, no. Placeholders doesn't work inside ^ ^ symbols too. Moreover, they doesn't work inside custom validators too. When I'm using number in custom validator - it works fine, but doesn't work, if I'm using `$modx->getPlaceholder('my_min_value')` instead. – VlLight Dec 26 '18 at 11:13
  • I think best bet is to use custom validator: https://docs.modx.com/extras/revo/formit/formit.validators#FormIt.Validators-CustomValidators – Zaigham R. Jan 22 '19 at 12:13