Development

#5330 (Symfony 1., generator.yml _save_and_list doesn't product correct action)

You must first sign up to be able to contribute.

Ticket #5330 (new defect)

Opened 7 months ago

Last modified 3 months ago

Symfony 1., generator.yml _save_and_list doesn't product correct action

Reported by: fotakis Assigned to: fabien
Priority: major Milestone:
Component: other Version:
Keywords: Cc:
Qualification: Unreviewed

Description

Using the new Admin Generator with Symfony 1.2.1, adding a _save_and_list to the edit actions, produces and invalid action + invalid input type for the _save_and_list option.

The problem is discussed here http://www.symfony-project.org/forum/index.php?t=rview&goto=67771&th=17493.

I have installed symfony using, the sandbox, as svn:externals and my

lib/symfony/plugins/sfPropelPlugin/data/generator/sfPropelAd min/default/template/actions/actions.class.php

is exactly the same, in all versions, which renders invalid the solution to reinstall symfony.

generator.yml

...

config:
      actions: ~
      fields:  ~
      list:    
         display:         [ =name ]
         batch_actions: {}
         object_actions:
              _delete: 
              shoe: 
      filter:  ~
      form:    ~
      edit:
         actions:
              _list: { label: Back }
              _save: { label: Save }
              _save_and_list: { label: Savel }
      new:     
         actions:
              _list: { label: Back }
              _save: { label: Save }
              _save_and_list: { label: Save1 }

HTML Output:

<form method="post" action="/backend_dev.php/collection">    <input type="hidden" name="collection[id]" id="collection_id" />
    
          <fieldset id="sf_fieldset_none">
  
                <div class="sf_admin_form_row sf_admin_text sf_admin_form_field_name">

        <div>
      <label for="collection_name">Name</label>
      <input type="text" name="collection[name]" id="collection_name" />
          </div>
  </div>
  </fieldset>
    
    <ul class="sf_admin_actions">
  <li class="sf_admin_action_list"><a href="/backend_dev.php/collection">Back</a></li>  <li class="sf_admin_action_save"><input type="submit" value="Save" /></li>  <li class="sf_admin_action_save_and_list">

  <a href="/backend_dev.php/collection//List_saveAndList">Savel</a>  </li>
</ul>
  </form>

Change History

12/16/08 11:57:39 changed by fotakis

  • version changed from 1.2.0 to 1.2.1.

02/26/09 23:45:15 changed by mathiasv

  • version changed from 1.2.1 to 1.2.4.

Same issue in 1.2.4 :

_save_and_list is not understood by sfPropelGenerator ( but with sfPropelAdminGenerator ). To make this working, you have to declare the helper linkTo_saveAndList, which is called in the _form_ations.php template, or _edit_actions.php. So, in modules/xxx/lib/projetGeneratorHelper.class.php, extends the generator helpers class :

class projetGeneratorHelper extends BaseProjetGeneratorHelper
{
  public function linkTo_saveAndList($object, $params)
  {
    return '<li class="sf_admin_action_save_and_list"><input type="submit" value="'.__($params['label'], array(), 'sf_admin').'" name="_save_and_list" /></li>';
  }  
}

And then, redeclare then processForm function in actions.class.php :

    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.');
  
        $projet = $form->save();
  
        $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $projet)));
  
        if ($request->hasParameter('_save_and_add'))
        {
          $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice').' You can add another one below.');
  
          $this->redirect('@projet_new');
        } elseif ($request->hasParameter('_save_and_list')) 
        {
          $this->getUser()->setFlash('notice', $this->getUser()->getFlash('notice') );
          $this->redirect('@projet_create');
        }
        else
        {
          $this->redirect('@projet_edit?id='.$projet->getId());
        }
      }
      else
      {
        $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.');
      }
    }

03/24/09 11:53:14 changed by pbowyer

  • version deleted.

I can confirm this is still present in 1.2.5-DEV, using Doctrine-generated admin modules. If the behaviour has disappeared for good, can this be documented? Otherwise a fix would be great

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.