Symfony: Using JavaScript in a onChange-event in a form and calling an action from the JS-Function -


i never used javascript before need in symfony-project (symfony 1.4) , have problems add code working:

i have template (indexsuccess) in module „aktionlimit“ show values of variables of object of class „aktion“ :

<p>value1: <?php echo $aktion->getvalue1()  ?></p> <p>value2: <?php echo $aktion->getvalue2()  ?></p> <p>value3: <?php echo $aktion->getvalue3()  ?></p>  <?php include_partial('form', array('form' => $form)) ?> 

this executeindex:

$this->aktion = aktionlimitpeer::getbyname($this->getuser()->getattribute('aktion'));  $aktionparam = new aktion(); $aktionparam->setname($this->aktion->getname());  $this->form = new aktionlimitform(array(), array("aktion" => $aktionparam)); 

the aktionlimitform looks this:

$aktionform = new aktionform($this->getoption('aktion'), array("limit" => true));  $this->embedform('aktion', $aktionform);    $this->widgetschema['neuerwert']= new sfwidgetforminputtext(); 

the embedded aktionform has 1 element (a dropdown-box includes unique names of objects of „aktion“):

$this->widgetschema['name'] = new sfwidgetformchoice(array('choices' =>   aktionpeer::gettypes()),array('onchange' => '???')); 

whenever user chooses „aktion“ in dropdown-box want load current object „aktion“ (referenced name) in executeindex , show values (value 1-3) in indexsuccess.(when submitting leads action.)

i need function calls executeindex in onchange-event. have declare function in web/js-folder, right?. how call function form? , how call action in javascript-function?

i hope understood i've written – today have difficulties explain problem in english :) help?

first of all, consider upgrading symfony 2.

then, don't need configure in form type, if decide use jquery (nice javascript framework). jquery can bind events elements easy.

$(document).ready( function() {     $('#id_of_the_form_field').change(function() {         // selected value         var selected = $(this).val()          // magic pony stuff     }); }); 

to call php actions javascript, need make ajax request related route.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -