本文整理汇总了PHP中sfForm::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::setDefault方法的具体用法?PHP sfForm::setDefault怎么用?PHP sfForm::setDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::setDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVisibleColumns
/**
* 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: processForm
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);
}
}