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 elements disappears after ->isValid

<?php
var_dump($form->get('keywordValue')); // OK
$form->isValid($parameters);
var_dump($form->get('keywordValue')); // FAIL! KeywordValue is not part of the form!

I also checked the ->getElements, its NULL ! Why?



28.1k

EDIT: I realized in the afterValidation() event I ->remove()-d an item. But only one.

Hmm tested your exact situation and it is working as intended. Can you share your afterValidation method or other code that modifies the form?

Here is my test:

var_dump($form->get('title')->getValue());
echo '<br/>';

$test = $form->isValid([]);

var_dump($test);
echo '<br/>';
var_dump($form->get('title')->getValue());

// Outputs
string(46) "Spanish town's giant dog dropping goes walkies" 
bool(false) 
string(46) "Spanish town's giant dog dropping goes walkies"