I have a dropdown in my Form:
class MyForm extends Phalcon\Forms\Form
{
public function initialize($entity=null,$options=null){
$mydrop = new Select ('mydrop', MyModel::find('some arguments'),array('using'=>array('id','name')));
$this->add($mydrop);
}
Then in the index.volt:
{{ form.render('mydrop'); }}
<div class="prefill_1"></div>
<div class="prefill_2"></div>
Controller:
class MyController extends Phalcon\Mvc\Controller
{
public function indexAction(){
$form = new MyForm();
$this->view->form = $form;
$mymodelslist = MyModel::find();
$this->view->model_list = $mymodellist;
}
}
MyModel has the following fields: id, name, adress1, address2. What I want to do is when the user selects a value from mydrop the volt references model_list to fill the two divs with address1 and address2 for the corresponding id selected in the dropdown.
I am sure this will require some ajax/jquery stuff but I am a serious n00b with that, so first off is this possible and if so how to do it? Thanks in advance!