public function executeDcWidgetFormJQueryDependenceChanged(sfWebRequest $request) { if ($request->isMethod('post')) { $widget_from_request = $request->getParameter('widget'); $widget = dcWidgetFormJQueryDependence::decodeWidget($widget_from_request); $observed_values = $request->getParameter('observed_values'); $this->getResponse()->setContent($widget->renderAfterUpdate($observed_values)); } return sfView::NONE; }
/** * Custom callback handler. You can overwrite it as your needs * * @param dcWidgetFormJQueryDependence $widget_dependece * @param array $values */ public static function updateColumn(dcWidgetFormJQueryDependence $widget_dependece, $values) { $multiple = $widget_dependece->getOption('observed_is_multiple'); $widget = $widget_dependece->getOption('widget'); $c = $widget->hasOption('criteria') ? $widget->getOption('criteria') : null; $c = is_null($c) ? new Criteria() : $c; foreach ($widget_dependece->getOption('related_column') as $id => $column) { if (!array_key_exists($id, $values)) { throw new LogicException("Index {$id} not found in received values"); } if (!empty($values[$id])) { $crit = $c->getNewCriterion($column, $values[$id], isset($multiple[$id]) && $multiple[$id] ? Criteria::IN : Criteria::EQUAL); if ($widget_dependece->getOption('or_null')) { $crit2 = $c->getNewCriterion($column, null, Criteria::ISNULL); $crit->addOr($crit2); } $c->addAnd($crit); } } $widget->setOption('criteria', $c); }