public function savePoliticoInstitucionList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['politico_institucion_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(PoliticoInstitucionPeer::INSTITUCION_ID, $this->object->getPrimaryKey());
     PoliticoInstitucionPeer::doDelete($c, $con);
     $values = $this->getValue('politico_institucion_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new PoliticoInstitucion();
             $obj->setInstitucionId($this->object->getPrimaryKey());
             $obj->setPoliticoId($value);
             $obj->save();
         }
     }
 }
Example #2
0
 public function configure()
 {
     unset($this['politico_lista_list'], $this['pais'], $this['created_at'], $this['partido_txt'], $this['sumu'], $this['sumd'], $this['politico_institucion_list'], $this['sf_guard_user_id'], $this['etiqueta_politico_list'], $this['etiqueta_lista_list'], $this['lista_calle_list']);
     $this->widgetSchema['sf_guard_user_profile_id'] = new sfWidgetFormChoice(array('choices' => array(), 'renderer_class' => 'sfWidgetFormPropelJQueryAutocompleter', 'renderer_options' => array('model' => 'Institucion', 'url' => $this->getOption('url'))));
     $this->embedI18n(array('es', 'ca'));
     $this->widgetSchema['sexo'] = new sfWidgetFormSelect(array('choices' => self::$generos));
     $this->widgetSchema['relacion'] = new sfWidgetFormSelect(array('choices' => self::$relaciones));
     $years = range(1920, date('Y'));
     $this->widgetSchema['fecha_nacimiento'] = new sfWidgetFormJQueryDate(array('culture' => 'es', 'format' => '%day%/%month%/%year%', 'years' => array_combine($years, $years)));
     $this->widgetSchema['imagen'] = new sfWidgetFormInputFileEditable(array('label' => 'Imagen Principal', 'file_src' => S3Voota::getImagesUrl() . '/politicos/cc_' . $this->getObject()->getImagen(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%  <img src="' . S3Voota::getImagesUrl() . '/politicos/bw_' . $this->getObject()->getImagen() . '"><br /><label></label>%input%<br /><label></label>%delete% Eliminar imagen actual</div>'));
     $this->validatorSchema['email'] = new sfValidatorEmail(array('required' => false));
     $this->validatorSchema['imagen'] = new sfValidatorFile(array('required' => false, 'mime_types' => 'web_images', 'path' => sfConfig::get('sf_upload_dir') . '/politicos', 'validated_file_class' => 'sfResizedFile'));
     if (!$this->isNew()) {
         // embed all enlace forms
         foreach ($this->getObject()->getEnlaces() as $enlace) {
             // create a new enlace form for the current enlace model object
             $enlaceForm = new PoliticoEnlaceForm($enlace);
             // embed the enlace form in the main politico form
             $this->embedForm('enlace' . $enlace->getId(), $enlaceForm);
             // set a custom label for the embedded form
             $this->widgetSchema['enlace' . $enlace->getId()]->setLabel('Enlace ' . $enlace->getId());
             // change the name widget to sfWidgetFormInputDelete
             $this->widgetSchema['enlace' . $enlace->getId()]['url'] = new sfWidgetFormInputDelete(array('url' => 'politico/deleteEnlace', 'model_id' => $enlace->getId(), 'confirm' => 'Sure???'));
         }
         // create a new enlace form for a new enlace model object
         $enlaceForm = new PoliticoEnlaceForm();
         // embed the enlace form in the main politico form
         $this->embedForm('enlace', $enlaceForm);
         // set a custom label for the embedded form
         $this->widgetSchema['enlace']->setLabel('Nuevo enlace');
     }
     if (!$this->isNew()) {
         // embed all institucion forms
         foreach ($this->getObject()->getPoliticoInstitucions() as $institucion) {
             // create a new insti form for the current insti model object
             $institucionForm = new PoliticoInstitucionForm($institucion);
             $institucionForm->setOption('url', $this->getOption('url'));
             $institucionForm->configure();
             // embed the institucion form in the main politico form
             $this->embedForm('institucion' . $institucion->getInstitucion()->getId(), $institucionForm);
             // set a custom label for the embedded form
             $this->widgetSchema['institucion' . $institucion->getInstitucion()->getId()]->setLabel('Institucion ' . $institucion->getInstitucion()->getId());
             // change the name widget to sfWidgetFormInputDelete
             /*
             $this->widgetSchema['institucion'.$institucion->getInstitucion()->getId()]['url'] = new sfWidgetFormInputDelete(array(
             	'url' => 'politico/deleteInstitucion',      // required
             	'model_id' => $institucion->getInstitucion()->getId(),        // required
             	'confirm' => 'Sure???',                     // optional
             ));
             */
         }
         // create a new institucion form for a new institucion model object
         $politicoInstitucion = new PoliticoInstitucion();
         $politicoInstitucion->setPoliticoId($this->getObject()->getId());
         $institucionForm = new PoliticoInstitucionForm($politicoInstitucion);
         $institucionForm->setOption('url', $this->getOption('url'));
         $institucionForm->configure();
         // embed the institucion form in the main politico form
         $this->embedForm('institucion', $institucionForm);
         // set a custom label for the embedded form
         $this->widgetSchema['institucion']->setLabel('Nueva instituciĆ³n');
     }
     $this->validatorSchema['imagen_delete'] = new sfValidatorBoolean();
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PoliticoInstitucion $value A PoliticoInstitucion object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PoliticoInstitucion $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getPoliticoId(), (string) $obj->getInstitucionId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }