Welcome Guest, Not a member yet? Register   Sign In
Displaying Validation errors - with more than a single {parm}
(This post was last modified: 11-26-2020, 06:09 AM by Gary.)

Here’s an easy one, to which I suspect the answer is “No”:

Is there a way that custom validation error messages can be customised to have MORE than a single {parm} injected into it?

The examples in the CI user guide indicate a possibility of having three fields injected in to the return: {value}, {field} and {parm}.  Many of the checks have only a single parameter to be checked, however there are some (like max_dims[]) that have two… and even if one uses the same variable name for the width and height, is still fails to inject the custom-spec’d number into {parm}:

In Validation:

'file' => [
'label' => …
'rules' => '…|max_dims[file_field,'.self::IMAGE_WIDTH_MAX','.self::IMAGE_HEIGHT_MAX_PX.']|…',

In the language error messages file:

'image' => [
  'file.label' => 'image',
  'file.max_dims' => 'The {field} file dimensions cannot exceed {parm}x{parm}px',

* I know there are other easy ways around this, but these effectively break/circumvent the mindset/consistent (and simple) manner that all the other parameter injections are done, making it a (frequently used) special case, which bothers me.

Theme © iAndrew 2016 - Forum software by © MyBB