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 change form element value?

given this code:

<?php
$form->get('a')->getValue(); // return 1
$form->get('a')->setDefault('2');
$form->get('a')->getValue(); // return 1, instead of 2

the last line returns an unexpected result, it still returns 1 instead of 2. setValue() doesnt even exists.



11.6k
edited May '16

on your controller:


    $this->tag->setDefault("yourInputID", "yourvalue");