本文整理汇总了PHP中sfForm::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::bind方法的具体用法?PHP sfForm::bind怎么用?PHP sfForm::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processForm
protected function processForm(sfWebRequest $request, sfForm $form, $emetteur, $asso)
{
$parameters = $request->getParameter($form->getName());
$form->bind($parameters, $request->getFiles($form->getName()));
if ($form->isValid()) {
$montant = abs($parameters['montant']);
var_dump(Doctrine);
$t = new Transaction();
// Transaction côté asso
$t_e = new Transaction();
// Transaction côté pôle
// Asso
$t->Asso = $asso;
$t_e->Asso = $emetteur;
// Compte
$t->compte_id = $parameters['asso_compte_id'];
$t_e->compte_id = $parameters['emetteur_compte_id'];
// Libellé
$t_e->libelle = sprintf('Avance de Trésorie %s', $asso->getName());
$t->libelle = sprintf('Avance de Trésorie %s', $emetteur->getName());
$t_e->montant = -($t->montant = $montant);
$t_e->commentaire = $t->commentaire = $parameters['commentaire'];
$t->moyen_id = $t_e->moyen_id = $parameters['moyen_id'];
$t->moyen_commentaire = $t_e->moyen_commentaire = $parameters['moyen_commentaire'];
$t->date_transaction = $t_e->date_transaction = date('Y-m-d');
$t->save();
$t_e->save();
$form->setValue('transaction_emetteur_id', $t_e);
$form->setValue('transaction_id', $t);
$form->setValue('asso_id', $asso->getPrimaryKey());
$avance_treso = $form->save();
$this->redirect('avances', $emetteur);
}
}
示例2: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$form->save();
}
}
示例3: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
try {
$stock = $form->save();
$stock->calc($stock->getDate());
} catch (Doctrine_Validator_Exception $e) {
$errorStack = $form->getObject()->getErrorStack();
$message = get_class($form->getObject()) . ' has ' . count($errorStack) . " field" . (count($errorStack) > 1 ? 's' : null) . " with validation errors: ";
foreach ($errorStack as $field => $errors) {
$message .= "{$field} (" . implode(", ", $errors) . "), ";
}
$message = trim($message, ', ');
$this->getUser()->setFlash('error', $message);
return sfView::SUCCESS;
}
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $stock)));
if ($request->hasParameter('_save_and_add')) {
$this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
$this->redirect('@stock_new');
} else {
$this->getUser()->setFlash('notice', $notice);
$this->redirect("stock/view?id=" . $stock->getId());
}
} else {
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
}
}
示例4: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$this->getUser()->setFlash('notice', $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.');
$new = !$form->getObject()->exists();
$site = $form->save();
if ($new) {
$dispatcher = $this->getContext()->getEventDispatcher();
$formatter = new sfFormatter();
chdir(sfConfig::get('sf_root_dir'));
$task = new sfGenerateAppTask($dispatcher, $formatter);
$task->run(array($site->slug));
$task = new sfSympalEnableForAppTask($dispatcher, $formatter);
$task->run(array($site->slug));
$task = new sfSympalCreateSiteTask($dispatcher, $formatter);
$task->run(array($site->slug), array('no-confirmation'));
$site = Doctrine_Core::getTable('sfSympalSite')->findOneByTitle($site->title);
}
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $site)));
if ($request->hasParameter('_save_and_add')) {
$this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') . ' You can add another one below.');
$this->redirect('@sympal_sites_new');
} else {
$this->redirect('@sympal_sites_edit?id=' . $site->getId());
}
} else {
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
}
}
示例5: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
// kommt vom multiupload-gedingse
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
$sf_filebase_file = $form->save();
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_filebase_file)));
if (!$request->hasParameter('swfupload_filesource')) {
if ($request->hasParameter('_save_and_add')) {
$this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
$this->redirect('@sf_filebase_file_new');
} else {
$this->getUser()->setFlash('notice', $notice);
$this->redirect(array('sf_route' => 'sf_filebase_file_edit', 'sf_subject' => $sf_filebase_file));
}
}
return true;
} else {
if (!$request->hasParameter('swfupload_filesource')) {
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
}
return false;
}
}
示例6: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$file = '';
$year = $form->getValue('years');
$semester = $form->getValue('semester');
$year = substr($year, 0, 4);
$form->getObject()->setYear($year . $semester);
if ($form->getValue('file_path') !== null || $form->getValue('file_path') != '') {
$myfile = $this->form->getObject()->getFilePath();
if ($myfile !== null || $myfile != '') {
//previously there was something there
$this->delExam($myfile);
}
$file = $form->getValue('file_path');
$dateTime = new DateTime('now');
$filename = '' . $dateTime->format(skuleadminConst::EXAM_FILE_DATEFORMAT) . '';
$extension = $file->getOriginalExtension();
$path = sfConfig::get('sf_web_dir') . skuleadminConst::INDIVIDUALEXAMFOLDER . $year . '/';
if ($file->save($path . $filename . $extension)) {
$exam = $form->save();
$this->redirect('adminexam/edit?id=' . $exam->getId());
} else {
$this->redirect('adminexam/failederr?msg=save');
}
} else {
$exam = $form->save();
$this->redirect('adminexam/edit?id=' . $exam->getId());
}
}
}
示例7: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
Doctrine_Manager::connection()->beginTransaction();
$Question = $form->save();
if ($Question->getIdQualifAgent() == 3) {
$venteForm = new VenteForm();
$venteForm->bind($request->getParameter('vente'));
if ($venteForm->isValid()) {
$vente = $venteForm->save();
Doctrine_Manager::connection()->commit();
} else {
Doctrine_Manager::connection()->rollback();
}
} else if ($Question->getIdQualifAgent() == 1) {
$rappelForm = new RappelForm();
$rappelForm->bind($request->getParameter('rappel'));
if ($rappelForm->isValid()) {
$rappel = $rappelForm->save();
Doctrine_Manager::connection()->commit();
} else {
Doctrine_Manager::connection()->rollback();
}
} else {
Doctrine_Manager::connection()->commit();
}
$this->redirect('question/next');
}
}
示例8: bind
public function bind(array $taintedValues = null, array $taintedFiles = null)
{
parent::bind($taintedValues, $taintedFiles);
if ($this->isValid()) {
$this->pager->setMaxPerPage($this->configuration->getExportationPagerMaxPerPage($this->getExportationType()));
}
}
示例9: bind
/**
* Overriding the bind for embedded forms
*
* @see lib/vendor/symfony/lib/form/sfForm#bind($taintedValues, $taintedFiles)
*/
public function bind(array $taintedValues = array(), array $taintedFiles = array())
{
parent::bind($taintedValues, $taintedFiles);
foreach ($this->embeddedForms as $name => $form) {
$form->bind($taintedValues[$name], $taintedFiles);
}
}
示例10: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$params = $request->getParameter($form->getName());
$this->forward404Unless($this->location = Doctrine::getTable('Location')->find(array($params['location_id'])), sprintf('Location does not exist (%s).', $params['location_id']));
$form->bind($params);
if ($form->isValid()) {
$detailsData = (array) json_decode($form->getValue('details'));
$photosData = (array) json_decode($form->getValue('photos'));
print_r($photosData);
die;
$form->save()->updateDetails($detailsData)->updatePhotos($photosData);
BotNet::create()->spammed($form->getObject(), 'description', $form->getObject()->getLocation()->getDateTimeObject('created_at')->format('U'));
if ($cache = $this->getContext()->getViewCacheManager()) {
$cache->remove('@sf_cache_partial?module=profit&action=_last&sf_cache_key=profit', '', 'all');
}
$this->redirect('profit/show?id=' . $form->getObject()->getId());
} else {
// foreach ($form->getFormFieldSchema() as $name => $formField) {
// if ($formField->getError() != "") {
// echo "ActionClassName::methodName( ): Field Error for :" . $name . " : " . $formField->getError();
// }
// }
}
return null;
}
示例11: bind
public function bind(array $taintedValues = array(), array $taintedFiles = array())
{
foreach ($taintedValues['sfAsset'] as $key => $val) {
$taintedValues['sfAsset'][$key]['folder_id'] = $taintedValues['parent_folder'];
}
parent::bind($taintedValues, $taintedFiles);
}
示例12: processForm
protected function processForm(sfWebRequest $request, sfForm $form, $celulaId = null)
{
$asistencia = $request->getParameter('reunion')['asistencias'];
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
$fields = $form->getFormFieldSchema()->getValue();
if ($form->isValid()) {
$reunion = $form->save();
foreach ($reunion->getAsistencias() as $borrable) {
$borrable->delete();
}
$asistencias = explode(',', $asistencia);
foreach ($asistencias as $key => $asistencia) {
if ($asistencia > 0) {
$source = new Asistencia();
$source->setReunionId($reunion->getId());
$source->setMiembroCelulaId($asistencia);
$source->save();
}
}
$this->getUser()->setFlash('notice', "Reunión guardada exitosamente", true);
if (isset($celulaId)) {
$this->redirect('celulas/show?id=' . $celulaId);
} else {
$this->forward('celulas', 'index');
}
}
$this->getUser()->setFlash('error', "Error!!! " . $form->getErrorSchema(), true);
if (isset($celulaId)) {
$this->redirect('celulas/show?id=' . $celulaId);
} else {
$this->forward('celulas', 'index');
}
}
示例13: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$value = $form->getValue('example');
$example = Doctrine_Core::getTable('Example')->find(array($value));
if ($example) {
$comment = $form->save();
$this->redirect('example/show?slug=' . $example->getSlug());
}
$value = $form->getValue('project');
$project = Doctrine_Core::getTable('Project')->find(array($value));
if ($project) {
$comment = $form->save();
$this->redirect('project/show?slug=' . $project->getSlug());
}
$value = $form->getValue('hint');
$hint = Doctrine_Core::getTable('Hint')->find(array($value));
if ($hint) {
$comment = $form->save();
$this->redirect('hint/show?slug=' . $hint->getSlug());
}
//????
//jaka akcja ma byc podjeta gdy brak example, project, hint?
//$comment = $form->save();
}
}
示例14: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid())
{
$isNew = $form->getObject()->isNew();
$notice = $isNew ? 'Your reply was saved successfully.' : 'The item was updated successfully.';
$sf_nested_comment = $form->save();
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $sf_nested_comment)));
$email_pref = sfNestedCommentConfig::isMailEnabled();
$enable_mail_alert = $email_pref === true || $email_pref == 'moderated';
if ($isNew && $enable_mail_alert && $sf_nested_comment->isReply())
{
$userComment = $sf_nested_comment->getsfNestedCommentRelatedBySfCommentId();
$params = $this->prepareMailParameter($sf_nested_comment, $userComment);
sfNestedCommentTools::sendEmail($this->getMailer(), $params);
}
$this->getUser()->setFlash('notice', $notice);
$this->redirect('@sf_nested_comment');
}
else
{
$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
}
}
开发者ID:nibsirahsieu,项目名称:sfNestedCommentPlugin,代码行数:30,代码来源:BasesfNestedCommentAdminActions.class.php
示例15: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$requestparam = $request->getParameter('accountentry');
$account = AccountTable::fetchById($requestparam['account_id']);
$qty = $requestparam['qty'];
$date = $requestparam['date']['year'] . "-" . $requestparam['date']['month'] . "-" . $requestparam['date']['day'];
//$ref_class=$requestparam['ref_class'];
//$ref_id=$requestparam['ref_id'];
$type = $requestparam['type'] != "" ? $requestparam['type'] : 'Adjustment';
//$priority=0;
$description = $requestparam['description'];
if ($qty == 0) {
$this->redirect('home/error?msg="Invalid Qty"');
}
$accountentry = $account->addEntry($date, $qty, null, null, $type, $description);
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
$notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $accountentry)));
$this->getUser()->setFlash('notice', $notice);
$this->redirect('account/view?id=' . $accountentry->getaccountId());
} else {
if ($form['qty']->getError()) {
$this->redirect('home/error?msg="Invalid Qty: ' . $qty . '"');
}
if ($form['date']->getError()) {
$this->redirect('home/error?msg="Invalid Date: ' . $date . '"');
}
//$this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
}
}