本文整理汇总了PHP中FormBuilder::getFormValues方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getFormValues方法的具体用法?PHP FormBuilder::getFormValues怎么用?PHP FormBuilder::getFormValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getFormValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processPost
/**
* Handle processing the form when it's posted, such as saving and handling errors.
*/
protected function processPost()
{
if (!$this->formObj) {
return false;
}
if ($this->formObj->formSubmitted()) {
// Form is valid, so save data
if ($this->formObj->formValid()) {
$originalFormValues = $this->formObj->getFormValues();
// Add optional filter to tweak the form values before saving
if ($this->filterBeforeSaveFunction && function_exists($this->filterBeforeSaveFunction)) {
$formValues = call_user_func($this->filterBeforeSaveFunction, $originalFormValues, $this);
} else {
$formValues = $originalFormValues;
}
// Now save the form values as normal.
$this->handleSave($formValues);
// Optional function once data has been saved
if ($this->afterSaveFunction && function_exists($this->afterSaveFunction)) {
call_user_func($this->afterSaveFunction, $formValues, $originalFormValues, $this);
}
} else {
$this->messages = $this->showListOfErrors($this->formObj->getListOfErrors());
}
}
}
示例2: processPost
/**
* Handle processing the form when it's posted, such as saving and handling errors.
*/
protected function processPost()
{
if (!$this->formObj) {
return false;
}
if ($this->formObj->formSubmitted()) {
// Form is valid, so save data
if ($this->formObj->formValid()) {
$originalFormValues = $this->formObj->getFormValues();
// Add optional function to validate the data
$gotFnErrorMsg = false;
if ($this->filterExtraValidationFunction && function_exists($this->filterExtraValidationFunction)) {
$gotFnErrorMsg = call_user_func($this->filterExtraValidationFunction, $originalFormValues, $this);
}
// Got an error message, so show and abort.
if ($gotFnErrorMsg) {
$this->messages = $this->showMessage($gotFnErrorMsg, true);
return false;
}
// Add optional filter to tweak the form values before saving
if ($this->filterBeforeSaveFunction && function_exists($this->filterBeforeSaveFunction)) {
$formValues = call_user_func($this->filterBeforeSaveFunction, $originalFormValues, $this);
// If we're modifying values, then we need to update the data being stored in the form
$this->loadDefaults($formValues);
} else {
$formValues = $originalFormValues;
}
// Now save the form values as normal.
$this->handleSave($formValues);
// Optional function once data has been saved
if ($this->afterSaveFunction && function_exists($this->afterSaveFunction)) {
call_user_func($this->afterSaveFunction, $formValues, $originalFormValues, $this);
}
} else {
$this->messages .= $this->showListOfErrors($this->formObj->getListOfErrors());
}
}
}