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 set default value to the text fields in volt from the values sent to the view from controller?

Hi, I want to set a default value to the text field which are sent to the view from controller . here i have sent the corporate_name from controller $this->view->corporate_name=$corporate_name

                           <div class="form-group" align="left" >
                                <p> Company Name</p>
                                <div class="controls">
                                    {{ text_field('user_name', 'class': "form-control",'readonly': 'true','value': {{corporate_name}} }}
                                </div>
                            </div>

How to do this?? Please Help!!!



338
{{ text_field('user_name', 'class': "form-control",'readonly': 'true','value': corporate_name ) }}


43.9k

hi,

you have to use:


// in controller

$this->tag->setDefault("user_name", $corporate_name);