public function savePoliticoListaList($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (!isset($this->widgetSchema['politico_lista_list'])) { // somebody has unset this widget return; } if (null === $con) { $con = $this->getConnection(); } $c = new Criteria(); $c->add(PoliticoListaPeer::LISTA_ID, $this->object->getPrimaryKey()); PoliticoListaPeer::doDelete($c, $con); $values = $this->getValue('politico_lista_list'); if (is_array($values)) { foreach ($values as $value) { $obj = new PoliticoLista(); $obj->setListaId($this->object->getPrimaryKey()); $obj->setPoliticoId($value); $obj->save(); } } }
public function configure() { unset($this['politico_lista_list'], $this['partido_lista_list']); $this->widgetSchema['sf_lista_id'] = new sfWidgetFormChoice(array('choices' => array(), 'renderer_class' => 'sfWidgetFormPropelJQueryAutocompleter', 'renderer_options' => array('model' => 'Politico', 'url' => $this->getOption('url')))); $this->widgetSchema['convocatoria_id'] = new sfWidgetFormChoice(array('choices' => array(), 'renderer_class' => 'sfWidgetFormPropelJQueryAutocompleter', 'renderer_options' => array('model' => 'Convocatoria', 'url' => $this->getOption('url_co')))); $this->widgetSchema['circunscripcion_id'] = new sfWidgetFormChoice(array('choices' => array(), 'renderer_class' => 'sfWidgetFormPropelJQueryAutocompleter', 'renderer_options' => array('model' => 'Circunscripcion', 'url' => $this->getOption('url_ci')))); if (!$this->isNew()) { // embed all forms foreach ($this->getObject()->getPoliticoListas() as $politico) { $politicoForm = new PoliticoListaForm($politico); $politicoForm->setOption('url', $this->getOption('url')); $politicoForm->configure(); $this->embedForm('politico' . $politico->getPolitico()->getId(), $politicoForm); // set a custom label for the embedded form $this->widgetSchema['politico' . $politico->getPolitico()->getId()]->setLabel('Político ' . $politico->getPolitico()->getId()); } $listaPolitico = new PoliticoLista(); $listaPolitico->setListaId($this->getObject()->getId()); $politicoForm = new PoliticoListaForm($listaPolitico); $politicoForm->setOption('url', $this->getOption('url')); $politicoForm->configure(); $this->embedForm('politico', $politicoForm); // set a custom label for the embedded form $this->widgetSchema['politico']->setLabel('Nuevo político'); $c = new Criteria(); $c->add(PoliticoListaPeer::LISTA_ID, $this->getObject()->getId()); $c->addAscendingOrderByColumn(PoliticoListaPeer::ORDEN); $this->listaPoliticos = PoliticoListaPeer::doSelect($c); } }