示例#1
0
 /**
  * Compute different sources to get the columns that must be showed
  * 1) from form request 2) from session 3) from default value
  * @param sfForm $form The form with the 'fields' field defined
  * @return array of fields with check or uncheck or a list of visible fields separated by |
  */
 private function getVisibleColumns(sfForm $form)
 {
     $flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'chrono', 'taxon_common_name', 'chrono_common_name', 'litho_common_name', 'lithologic_common_name', 'mineral_common_name', 'expedition', 'individual_type', 'litho', 'lithologic', 'mineral', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'specimen_count', 'object_name');
     $flds = array_fill_keys($flds, 'uncheck');
     if ($form->isBound()) {
         $req_fields = $form->getValue('col_fields');
         if ($form->getValue('taxon_common_name') != '' || $form->getValue('taxon_name') != '') {
             $req_fields .= '|taxon|taxon_common_name';
         }
         if ($form->getValue('chrono_common_name') != '' || $form->getValue('chrono_name') != '') {
             $req_fields .= '|chrono|chrono_common_name';
         }
         if ($form->getValue('litho_common_name') != '' || $form->getValue('litho_name') != '') {
             $req_fields .= '|litho|litho_common_name';
         }
         if ($form->getValue('lithology_common_name') != '' || $form->getValue('lithology_name') != '') {
             $req_fields .= '|lithologic|lithology_common_name';
         }
         if ($form->getValue('mineral_common_name') != '' || $form->getValue('mineral_name') != '') {
             $req_fields .= '|mineral|mineral_common_name';
         }
         if ($form->getValue('search_type', 'zoo') == 'zoo') {
             if (!strpos($req_fields, 'common_name')) {
                 $req_fields .= '|taxon|taxon_common_name';
                 // add taxon by default if there is not other catalogue
             }
         } else {
             if (!strpos($req_fields, 'common_name')) {
                 $req_fields .= '|chrono|litho|lithologic|mineral';
             }
             // add cols by default if there is not other catalogue
         }
         $req_fields_array = explode('|', $req_fields);
     }
     if (empty($req_fields_array)) {
         $req_fields_array = explode('|', $form->getDefault('col_fields'));
     }
     foreach ($req_fields_array as $k => $val) {
         $flds[$val] = 'check';
     }
     $form->setDefault('col_fields', $req_fields);
     return $flds;
 }
示例#2
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $tipoDiscipulo = $form->getValue('tipo_discipulo');
         $form->setDefault('groups_list', array(0 => $tipoDiscipulo));
         $sf_guard_user = $form->save();
         $nombre_foto = $sf_guard_user->getfotografia();
         if ($nombre_foto) {
             Utilitarios::cambiarFoto($nombre_foto);
         }
         $this->getUser()->setFlash('notice', 'La información fue guardada correctamente ', false);
         //            $this->redirect('disipulos/edit?id=' . $sf_guard_user->getId());
         $this->forward('disipulos', 'index');
     } else {
         $this->getUser()->setFlash('error', 'No se pudieron guardar los cambios, revise los mensajes de error', false);
     }
 }