コード例 #1
0
ファイル: actions.class.php プロジェクト: Chipusy/lkbroker
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $notice = $form->getObject()->isNew() ? 'Категория создана успешно.' : 'Категория изменена успешно.';
         $Category = $form->save();
         foreach ((array) $request->getParameter('category_preference') as $key => $value) {
             if (isset($value['id']) and $value['id'] != 0) {
                 $category_preference = CategoryPreferencePeer::retrieveByPk(intval($value['id']));
             } else {
                 $category_preference = new CategoryPreference();
                 $category_preference->setCategoryId($form->getObject()->getId());
             }
             if (isset($value['delete'])) {
                 $category_preference->delete();
             } elseif ($value['name'] != '') {
                 $category_preference->setKey($value['name']);
                 $category_preference->setPreferenceType($value['preference_type']);
                 $category_preference->setPreferenceUnit($value['preference_unit']);
                 $category_preference->setFilterStatus(isset($value['filter_status']) ? $value['filter_status'] : 0);
                 $category_preference->save();
             }
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Category)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' Вы можете создать еще одну.');
             $this->redirect('@category_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'category_edit', 'sf_subject' => $Category));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }
コード例 #2
0
ファイル: BasePreference.php プロジェクト: Chipusy/lkbroker
 /**
  * Get the associated CategoryPreference object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     CategoryPreference The associated CategoryPreference object.
  * @throws     PropelException
  */
 public function getCategoryPreference(PropelPDO $con = null)
 {
     if ($this->aCategoryPreference === null && $this->category_preference_id !== null) {
         $this->aCategoryPreference = CategoryPreferencePeer::retrieveByPk($this->category_preference_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aCategoryPreference->addPreferences($this);
         		 */
     }
     return $this->aCategoryPreference;
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: Chipusy/lkbroker
 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.';
         $Category = $form->save();
         foreach ((array) $request->getParameter('category_preference') as $key => $value) {
             if (isset($value['id'])) {
                 $category_preference = CategoryPreferencePeer::retrieveByPk(intval($value['id']));
             } else {
                 $category_preference = new CategoryPreference();
                 $category_preference->setCategoryId($form->getObject()->getId());
             }
             if (isset($value['delete'])) {
                 $category_preference->delete();
             } elseif ($value['name'] != '') {
                 $category_preference->setKey($value['name']);
                 $category_preference->setFilterStatus(isset($value['filter_status']) ? $value['filter_status'] : 0);
                 $category_preference->save();
             }
         }
         $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $Category)));
         if ($request->hasParameter('_save_and_add')) {
             $this->getUser()->setFlash('notice', $notice . ' You can add another one below.');
             $this->redirect('@category_new');
         } else {
             $this->getUser()->setFlash('notice', $notice);
             $this->redirect(array('sf_route' => 'category_edit', 'sf_subject' => $Category));
         }
     } else {
         $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
     }
 }