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

Form collection

Hello. I searched everywhere and found nothing. Can you help me? How to use the collection in the form?

<form method="post" name="form" action="index.php">
    <input name="ext[0][image]" value="">
    <textarea name="ext[0][description]" maxlength="120"></textarea>

    <input name="ext[1][image]" value="">
    <textarea name="ext[1][description]" maxlength="120"></textarea>

    <input name="ext[2][image]" value="">
    <textarea name="ext[2][description]" maxlength="120"></textarea>
    <input name="submit-form" type="submit">
</form>

Hi!

After submit form in controller you can get data

$user_data = $this->getDi()->get('request')->getPost(); 

$user_data will be array:

[
    'ext' => [
        0 => [
            'image' => '....',
            'description' => '....',
        ],
        1 => [
            'image' => '....',
            'description' => '....',
        ],
        3 => [
            'image' => '....',
            'description' => '....',
        ],
    ],
    'submit-form' => '',
]

It's what you need?



12.4k

No. I'm talking about how to create fields using the form of phalcon. How validate these fields. In Zend framework 2 I used collection.

Oh sory!

Please, read this article https://docs.phalcon.io/en/latest/reference/forms.html

Notice 1: every form element just call function from Phalcon\Tag, so if you need to know what params may accept Phalcon\Forms\Element\<some element> view https://docs.phalcon.io/en/latest/reference/tags.html and https://github.com/phalcon/cphalcon/blob/master/phalcon/tag.zep

If after reading you still have any questions please write its.



12.4k

Thank you

Forum posting is very important in SEO. And your forum collection is good . Gustavo Woltmann