Skip to content
Permalink
Browse files

Modified so as not to create a communityFileForm class if do not use …

…file upload(refs #3729, BP from #3588)
  • Loading branch information...
isaosano committed May 27, 2015
1 parent 101f5cf commit 7b5ce17f48faaa4c4ccaa706ceda853665b4f50a
@@ -140,4 +140,15 @@ public function executeDeleteImage(opWebRequest $request)
$this->redirect('community/configImage?id='.$this->id);
}
}
/**
* Executes edit action
*
* @param sfRequest $request A request object
*/
public function executeEdit(opWebRequest $request)
{
$this->unusedFileForm = true;
return parent::executeEdit($request);
}
}
@@ -91,22 +91,32 @@ public function executeEdit(opWebRequest $request)
$this->communityForm = new CommunityForm($this->community);
$this->communityConfigForm = new CommunityConfigForm(array(), array('community' => $this->community));
$this->communityFileForm = new CommunityFileForm(array(), array('community' => $this->community));
if (!$this->unusedFileForm){$this->communityFileForm = new CommunityFileForm(array(), array('community' => $this->community));}
if ($request->isMethod('post'))
{
$params = $request->getParameter('community');
$params['id'] = $this->id;
$this->communityForm->bind($params);
$this->communityConfigForm->bind($request->getParameter('community_config'));
$this->communityFileForm->bind($request->getParameter('community_file'), $request->getFiles('community_file'));
if ($this->communityForm->isValid() && $this->communityConfigForm->isValid() && $this->communityFileForm->isValid())
if($this->communityFileForm)
{
$this->communityFileForm->bind($request->getParameter('community_file'), $request->getFiles('community_file'));
if ($this->communityForm->isValid() && $this->communityConfigForm->isValid() && $this->communityFileForm->isValid())
{
$this->communityForm->save();
$this->communityConfigForm->save();
$this->communityFileForm->save();
$this->redirect('@community_home?id='.$this->community->getId());
}
}
elseif ($this->communityForm->isValid() && $this->communityConfigForm->isValid())
{
$this->communityForm->save();
$this->communityConfigForm->save();
$this->communityFileForm->save();
$this->communityForm->save();
$this->communityConfigForm->save();
$this->redirect('@community_home?id='.$this->community->getId());
$this->redirect('@community_home?id='.$this->community->getId());
}
}
}

0 comments on commit 7b5ce17

Please sign in to comment.
You can’t perform that action at this time.