We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to validate array post value in phalcon

I am new in phalcon . so i have hard working with validate an array in post request example i have website using multi language and i need validator

<input name="description[1][title]" />
<input name="description[1][description]" />
<textare name="description[2][title]"></textare>
<textare name="description[2][description]"></textare>

How to validate array value in post with format message like

errors [
    'description':  [
        1:  [
            [ 'title'   => 'title is require'],
            [ 'description' => 'description is require']
        ],
        2: [
            [ 'title'   => 'title is require'],
            [ 'description' => 'description is require']
        ]
    ]
]

like this so i can handle to display error in the html with the key is language id .

Sorry for my bad english ! Thanks

If you use forms you can add elements and their validators with custom error messages

If you use tags::forms elements you can check element name and if it a error message to show

Good luck

I am using micro ! form not support !

If you use forms you can add elements and their validators with custom error messages

If you use tags::forms elements you can check element name and if it a error message to show

Good luck

There are two issues here.

1) How to know if a field is invalid It is difficult to give you a simple answer because there are many different ways this can be accomplished. You could simply iterate through $_POST. Or you could assign title and description to a Model, and set up validation in the model.

2) How to tell the user in the correct language. Have you looked into Phalcon's Translate functionality: https://docs.phalcon.io/en/3.4/translate