Yeah, I would create an action that returned a json object and create
the new <select> from that.

On Wed, Jan 12, 2011 at 11:16 AM, Tom Haskins-Vaughan
<[email protected]> wrote:
> Can you not set the service type on the object before you pass it to the form?
>
> $calculation = new Calculation();
> $calculation->setServiceType($my_value);
>
> $form = new CalculationForm($calculation);
>
> On Wed, Jan 12, 2011 at 8:12 AM, Emil Rømer Christensen
> <[email protected]> wrote:
>> This is my Form class:
>>
>> class CalculationForm extends BaseCalculationForm {
>>
>>  private $service_type_id = 0;
>>
>>  public function configure() {
>>    $this->useFields(array('model_id', 'motor_id',
>> 'service_type_id'));
>>
>>    $this->widgetSchema['model_id']->setOption('add_empty',
>> 'Choose...');
>>
>>    $this->widgetSchema['motor_id']->setOption('add_empty',
>> 'Choose...');
>>
>>    $this->widgetSchema['service_type_id']->setOption('add_empty',
>> 'Choose...');
>>
>>    $month_query = Doctrine::getTable('Month')->createQuery('m')-
>>>where('m.service_type_id = ?', $this->service_type_id);
>>
>>    $this->widgetSchema['months'] = new
>> sfWidgetFormDoctrineChoice(array(
>>      'model'     => 'Month',
>>      'add_empty' => 'Choose...',
>>      'query'     => $month_query
>>    ));
>>
>>    $milage_query = Doctrine::getTable('Milage')->createQuery('m')-
>>>where('m.service_type_id = ?', $this->service_type_id);
>>
>>    $this->widgetSchema['milage'] = new
>> sfWidgetFormDoctrineChoice(array(
>>      'model'     => 'Milage',
>>      'add_empty' => 'Choose...',
>>      'query'     => $milage_query
>>    ));
>>  }
>>
>>  public function getServiceTypeId() {
>>    return $this->service_type_id;
>>  }
>>
>>  public function setServiceTypeId($service_type_id) {
>>    $this->service_type_id = $service_type_id;
>>  }
>>
>> }
>>
>> What I can't get working atm is that the call from my action to the
>> setServiceTypeId() from my actions.class.php
>>
>> $this->form = new CalculationForm();
>> $this->form->setServiceTypeId(1);
>>
>> It doesn't seem to work when I invoke the method from the executeIndex
>> to pre-populate the select box.
>>
>> For the AJAX I think I need to make a method in actions that I call
>> from jQuery with .load() then have it return a JSON array with the
>> info for the new options.
>>
>> --
>> If you want to report a vulnerability issue on symfony, please send it to 
>> security at symfony-project.com
>>
>> You received this message because you are subscribed to the Google
>> Groups "symfony users" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/symfony-users?hl=en
>>
>
>
>
> --
> The Harvest Cloud
> Who says buying local food can't be easy?
>
> Find out more @ harvestcloud.com
>



-- 
The Harvest Cloud
Who says buying local food can't be easy?

Find out more @ harvestcloud.com

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to