How to set default value in form field using form object in Social Engine

Sometime client wants to set some default values for form fields. For example get the user current location and set it to location Text field. So for this we have setValue('value') function we can used this function using following way:

First define the form object

$this->view->form = $form = new Blog_Form_Create();

After that let's assume we have location form field in our form so in controllers how to set location field value

$form->location->setValue(value that you want set)

So on front end when form is display you will see location form element set with some default value. Please check the below screenshot

Set form value



Post a comment

1 Comments