Créer un compte ou loggez-vous pour pouvoir ajouter, commenter et noter les snippets.

Navigation

Tags relatifs

my Symfony Plugins

Plugins demos


My bookmarks

Vous pouvez commenter/noter en utilisant le compte anonymous (mot de passe: anonymous)
You can comment/rate using the anonymous account (password: anonymous).

Snippets taggés : "action" Snippets taggés : "action"

[symfony 1.2] Charger un groupe d'helper depuis une action ou le modèle - 586 view(s)

Donc permet de charger un helper depuis un contexte autre que depuis les templates:

sfProjectConfiguration::getActive()->loadHelpers(array('Url'));

Tip original

par COil le 2009-03-22, taggé : action  configuration  context  helper  symfony 
(1 commentaire)

[symfony 1.1] Gestion de formulaire typique - 281 view(s)

  /**
   * Ad publication form for the users.
   * 
   * @todo : Eventually save posted datas in session to be able to retrieve
   * values even when changer the main category of the ad. 
   */
  public function executePost($request)
  {
    // Default ad_base object
    $ad_base = $this->getAdBaseOrCreate($request);
 
    // Secure edition
    if (!$ad_base->isNew())
    {
      $this->forward404Unless($ad_base && ($ad_base->getIpAdContact()->getCreatedBy() == $this->getUser()->getId()));
    }
 
    // Form and params
    $ip_ad_base_post = $request->getParameter('ip_ad_base');
    $form = new ipAdPostForm($ad_base, $ip_ad_base_post);    
    $category_refresh = isset($ip_ad_base_post['category_refresh']) ? $ip_ad_base_post['category_refresh'] : 0;
 
    // Refresh category and save submitted form values (without input validation)
    if ($category_refresh)
    {
      $ip_ad_base_post['category_refresh'] = 0;
      $form->setDefaults($ip_ad_base_post);
    }
 
    // Post and save form
    if (!$category_refresh && $this->isPost() && $ip_ad_base_post)
    {
      $form->bind($ip_ad_base_post, $request->getFiles('ip_ad_base'));
 
      if ($form->isValid())
      {
        $form->save();
 
        // Photo deletion
        if ($delete_flag = $form->hasDeletePhotoFlag() && !$ad_base->isNew())
        {
          $ad_base->deletePhoto();
        }
 
        // Photo upload
        if (!$delete_flag && $form->hasPhoto())
        {
          $form->saveAndUploadPhoto($request);
        }
 
        // Send email to administrator if it is a new ad to validate
        //if ($form->getObject()->isNew())
        //{
          //ipTools::dump('send email', 'send email', 1);
          $form->getObject()->notifyWebmasterForNewAd();
        //}
 
        // Redirect
        $this->getUser()->addNotice('Votre annonce a été sauvegardée, elle sera visible dès qu\'elle aura été validée par un administrateur');
        $this->redirect('iposte_user/adsList');
      }
    }
 
    // Pass form to template
    $this->form = $form;
  }
 
par COil le 2008-09-29, taggé : action  form  post  symfony 
(1 commentaire)

[symfony 1.0] Supprimer le bouton create dans la liste d'un admin gen - 148 view(s)

      actions: { }
 
par COil le 2008-09-29, taggé : action  admingenerator  create  symfony  yml 
(1 commentaire)

[symfony 1.0] Retourner du text de partial à partir de l'action - 174 view(s)

Typiquement pour une action Ajax:

    if (!$this->user)
    {
      sfLoader::loadHelpers('Partial');
      return $this->renderText(get_partial('member/rdv/list'));
    }
 
par COil le 2008-09-29, taggé : action  ajax  helper  partial  symfony 
(1 commentaire)

[symfony 1.0] Get the current action instance - 357 view(s)

$action_instance = sfContext::getInstance()->getController()->getActionStack()->getFirstEntry()->getActionInstance();
 
par COil le 2008-09-29, taggé : action  context  instance  symfony 
(1 commentaire)

[symfony] Passer des paramètres à une action avant un forward - 107 view(s)

$this->getRequest()->setParameter('confirm', true);
$this->forward('users', 'index');
 
par COil le 2008-09-28, taggé : action  forward  parameters  symfony 

[symfony] Utiliser un helper dans une classe action - 318 view(s)

sfLoader::loadHelpers(array('First', 'Second'));
 
par COil le 2008-09-28, taggé : action  helper  loader  symfony 
(1 commentaire)

[symfony 1.0] Test si un formulaire a été posté - 135 view(s)

if ($this->getRequest()->getMethod() == sfRequest::POST) {
    // $this->actionWhenPosted()
}
 
par COil le 2008-09-28, taggé : action  form  post  symfony 
Debug toolbar