Hi
You don't need to define in the generator.yml the type doublelist.
If you model is ok,
the form will have a widget : tags_list (widget select many)
example of schema.yml n:m to have a widget categories_list in the
ProductForm :
Category:
columns:
id:
type: integer(4)
primary: true
notnull: true
autoincrement: true
name:
type: string(45)
notnull: true
Product:
columns:
id:
type: integer(4)
primary: true
notnull: true
autoincrement: true
name:
type: string(45)
notnull: true
relations:
categories:
class: Category
local: Product_id
foreign: Category_id
refClass: CategoryProduct
foreignAlias: Products
CategoryProduct:
columns:
Category_id:
type: integer(4)
primary: true
notnull: true
Product_id:
type: integer(4)
primary: true
notnull: true
relations:
Category:
local: Category_id
foreign: id
foreignAlias: CategoryProduct
Product:
local: Product_id
foreign: id
foreignAlias: CategoryProduct
options:
type: InnoDB
On Nov 30, 12:21 pm, Greg Romanssen <[email protected]> wrote:
> Hello,
>
> trying to learn how to use doctrine_admin_double_list that is listed
> inhttp://www.symfony-project.org/book/1_2/14-Generators
>
> I created schema.yml with tables Tag, BlogPost, BlogPostTag and created
> admin.
> M:N works well but I would like that nice admin_double_list.
>
> I edited generator.yml of blogpost module to this:
>
> generator:
> class: sfDoctrineGenerator
> param:
> model_class: BlogPost
> theme: admin
> non_verbose_templates: true
> with_show: false
> singular: BlogPost
> plural: BlogPosts
> route_prefix: blog_post
> with_doctrine_route: true
> actions_base_class: sfActions
>
> config:
> actions: ~
> fields: ~
> list: ~
> filter: ~
> form: ~
> edit:
> title: Editace
> fields:
> BlogPostTag:
> name: Tagy
> type: doctrine_admin_double_list
> display:
> [BlogPostTag]
> new: ~
>
> Unfortunately site reports this:
>
> 500 | Internal Server Error | InvalidArgumentException
>
> Widget "BlogPostTag" does not exist.
>
> stack trace
>
> * at **()
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\form\sfForm.class.php/ line
> 1049 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 1046. {
> 1047. if (!$widget = $this->widgetSchema[$name])
> 1048. {
> 1049. throw new InvalidArgumentException(sprintf('Widget
> "%s" does not exist.', $name));
> 1050. }
> 1051.
>
> 1052. if ($this->isBound)
> * at *sfForm->offsetGet*('BlogPostTag')
> in
>
> /SF_ROOT_DIR\cache\backend\dev\modules\autoBlogpost\templates\_form_field.php/
> line 6 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 3. <?php elseif ($field->isComponent()): ?>
> 4. <?php include_component('blogpost', $name, array('form'
> => $form, 'attributes' => $attributes instanceof sfOutputEscaper ?
> $attributes->getRawValue() : $attributes)) ?>
> 5. <?php else: ?>
> 6. <div class="<?php echo $class ?><?php
> $form[$name]->hasError() and print ' errors' ?>">
> 7. <?php echo $form[$name]->renderError() ?>
> 8. <div>
> 9. <?php echo $form[$name]->renderLabel($label) ?>
> * at
>
> *require*('C:\work\www\symfony\cache\backend\dev\modules\autoBlogpost\templates\_form_field.php')
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPHPView.class.php/
> line 72 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 69. // render
> 70. ob_start();
> 71. ob_implicit_flush(0);
> 72. require($_sfFile);
> 73.
>
> 74. return ob_get_clean();
> 75. }
> * at
>
> *sfPHPView->renderFile*('C:\work\www\symfony\cache\backend\dev\modules/autoBlogpost/templates/_form_field.php')
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPartialView.class.php/
> line 110 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 107. $this->getAttributeHolder()->set('sf_type',
> 'partial');
> 108.
>
> 109. // render template
> 110. $retval =
> $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
> 111. }
> 112. catch (Exception $e)
> 113. {
> * at *sfPartialView->render*()
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\helper\PartialHelper.php/
> line 218 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 215. $view = new $class($context, $moduleName, $actionName,
> '');
> 216. $view->setPartialVars($vars);
> 217.
>
> 218. return $view->render();
> 219. }
> 220.
>
> 221. /**
> * at *get_partial*('blogpost/form_field', /array/('name' =>
> 'BlogPostTag', 'attributes' =>
> /object/('sfOutputEscaperArrayDecorator'), 'label' => /null/,
> 'help' => /null/, 'form' => /object/('BlogPostForm'), 'field' =>
> /object/('sfOutputEscaperObjectDecorator'), 'class' =>
> 'sf_admin_form_row sf_admin_text sf_admin_form_field_BlogPostTag'))
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\helper\PartialHelper.php/
> line 180 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 177. */
> 178. function include_partial($templateName, $vars = array())
> 179. {
> 180. echo get_partial($templateName, $vars);
> 181. }
> 182.
>
> 183. /**
> * at *include_partial*('blogpost/form_field', /array/('name' =>
> 'BlogPostTag', 'attributes' =>
> /object/('sfOutputEscaperArrayDecorator'), 'label' => /null/,
> 'help' => /null/, 'form' => /object/('BlogPostForm'), 'field' =>
> /object/('sfOutputEscaperObjectDecorator'), 'class' =>
> 'sf_admin_form_row sf_admin_text sf_admin_form_field_BlogPostTag'))
> in
>
> /SF_ROOT_DIR\cache\backend\dev\modules\autoBlogpost\templates\_form_fieldset.php/
> line 16 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 13. 'form' => $form,
> 14. 'field' => $field,
> 15. 'class' => 'sf_admin_form_row
> sf_admin_'.strtolower($field->getType()).' sf_admin_form_field_'.$name,
> 16. )) ?>
> 17. <?php endforeach; ?>
> 18. </fieldset>
> 19.
>
> * at
>
> *require*('C:\work\www\symfony\cache\backend\dev\modules\autoBlogpost\templates\_form_fieldset.php')
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPHPView.class.php/
> line 72 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 69. // render
> 70. ob_start();
> 71. ob_implicit_flush(0);
> 72. require($_sfFile);
> 73.
>
> 74. return ob_get_clean();
> 75. }
> * at
>
> *sfPHPView->renderFile*('C:\work\www\symfony\cache\backend\dev\modules/autoBlogpost/templates/_form_fieldset.php')
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPartialView.class.php/
> line 110 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 107. $this->getAttributeHolder()->set('sf_type',
> 'partial');
> 108.
>
> 109. // render template
> 110. $retval =
> $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
> 111. }
> 112. catch (Exception $e)
> 113. {
> * at *sfPartialView->render*()
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\helper\PartialHelper.php/
> line 218 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 215. $view = new $class($context, $moduleName, $actionName,
> '');
> 216. $view->setPartialVars($vars);
> 217.
>
> 218. return $view->render();
> 219. }
> 220.
>
> 221. /**
> * at *get_partial*('blogpost/form_fieldset', /array/('BlogPost' =>
> /object/('sfOutputEscaperIteratorDecorator'), 'form' =>
> /object/('BlogPostForm'), 'fields' =>
> /object/('sfOutputEscaperArrayDecorator'), 'fieldset' => 'NONE'))
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\helper\PartialHelper.php/
> line 180 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 177. */
> 178. function include_partial($templateName, $vars = array())
> 179. {
> 180. echo get_partial($templateName, $vars);
> 181. }
> 182.
>
> 183. /**
> * at *include_partial*('blogpost/form_fieldset', /array/('BlogPost'
> => /object/('sfOutputEscaperIteratorDecorator'), 'form' =>
> /object/('BlogPostForm'), 'fields' =>
> /object/('sfOutputEscaperArrayDecorator'), 'fieldset' => 'NONE'))
> in
> /SF_ROOT_DIR\cache\backend\dev\modules\autoBlogpost\templates\_form.php/
> line 13 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 10. <?php endif; ?>
> 11.
>
> 12. <?php foreach ($configuration->getFormFields($form,
> $form->isNew() ? 'new' : 'edit') as $fieldset => $fields): ?>
> 13. <?php include_partial('blogpost/form_fieldset',
> array('BlogPost' => $BlogPost, 'form' => $form, 'fields' => $fields,
> 'fieldset' => $fieldset)) ?>
> 14. <?php endforeach; ?>
> 15.
>
> 16. <?php include_partial('blogpost/form_actions',
> array('BlogPost' => $BlogPost, 'form' => $form, 'configuration' =>
> $configuration, 'helper' => $helper)) ?>
> * at
>
> *require*('C:\work\www\symfony\cache\backend\dev\modules\autoBlogpost\templates\_form.php')
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPHPView.class.php/
> line 72 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 69. // render
> 70. ob_start();
> 71. ob_implicit_flush(0);
> 72. require($_sfFile);
> 73.
>
> 74. return ob_get_clean();
> 75. }
> * at
>
> *sfPHPView->renderFile*('C:\work\www\symfony\cache\backend\dev\modules/autoBlogpost/templates/_form.php')
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPartialView.class.php/
> line 110 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 107. $this->getAttributeHolder()->set('sf_type',
> 'partial');
> 108.
>
> 109. // render template
> 110. $retval =
> $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
> 111. }
> 112. catch (Exception $e)
> 113. {
> * at *sfPartialView->render*()
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\helper\PartialHelper.php/
> line 218 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 215. $view = new $class($context, $moduleName, $actionName,
> '');
> 216. $view->setPartialVars($vars);
> 217.
>
> 218. return $view->render();
> 219. }
> 220.
>
> 221. /**
> * at *get_partial*('blogpost/form', /array/('BlogPost' =>
> /object/('sfOutputEscaperIteratorDecorator'), 'form' =>
> /object/('BlogPostForm'), 'configuration' =>
> /object/('sfOutputEscaperObjectDecorator'), 'helper' =>
> /object/('blogpostGeneratorHelper')))
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\helper\PartialHelper.php/
> line 180 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 177. */
> 178. function include_partial($templateName, $vars = array())
> 179. {
> 180. echo get_partial($templateName, $vars);
> 181. }
> 182.
>
> 183. /**
> * at *include_partial*('blogpost/form', /array/('BlogPost' =>
> /object/('sfOutputEscaperIteratorDecorator'), 'form' =>
> /object/('BlogPostForm'), 'configuration' =>
> /object/('sfOutputEscaperObjectDecorator'), 'helper' =>
> /object/('blogpostGeneratorHelper')))
> in
>
> /SF_ROOT_DIR\cache\backend\dev\modules\autoBlogpost\templates\editSuccess.php/
> line 14 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 11. </div>
> 12.
>
> 13. <div id="sf_admin_content">
> 14. <?php include_partial('blogpost/form', array('BlogPost'
> => $BlogPost, 'form' => $form, 'configuration' => $configuration, 'helper' =>
> $helper)) ?>
> 15. </div>
> 16.
>
> 17. <div id="sf_admin_footer">
> * at
>
> *require*('C:\work\www\symfony\cache\backend\dev\modules\autoBlogpost\templates\editSuccess.php')
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPHPView.class.php/
> line 72 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 69. // render
> 70. ob_start();
> 71. ob_implicit_flush(0);
> 72. require($_sfFile);
> 73.
>
> 74. return ob_get_clean();
> 75. }
> * at
>
> *sfPHPView->renderFile*('C:\work\www\symfony\cache\backend\dev\modules/autoBlogpost/templates/editSuccess.php')
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\view\sfPHPView.class.php/
> line 169 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 166. $this->attributeHolder->set('sf_type', 'action');
> 167.
>
> 168. // render template file
> 169. $content =
> $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
> 170.
>
> 171. if (sfConfig::get('sf_cache') && null !== $uri)
> 172. {
> * at *sfPHPView->render*()
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfExecutionFilter.class.php/
> line 153 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 150. break;
> 151.
>
> 152. case sfView::RENDER_CLIENT:
> 153. $viewData = $view->render();
> 154.
> $this->context->getResponse()->setContent($viewData);
> 155. break;
> 156.
>
> * at *sfExecutionFilter->executeView*('blogpost', 'edit', 'Success',
> /array/('configuration' =>
> /object/('blogpostGeneratorConfiguration'), 'helper' =>
> /object/('blogpostGeneratorHelper'), 'BlogPost' =>
> /object/('BlogPost'), 'form' => /object/('BlogPostForm')))
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfExecutionFilter.class.php/
> line 114 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 111. return;
> 112. }
> 113.
>
> 114. $this->executeView($actionInstance->getModuleName(),
> $actionInstance->getActionName(), $viewName,
> $actionInstance->getVarHolder()->getAll());
> 115. }
> 116.
>
> 117. /**
> * at *sfExecutionFilter->handleView*(/object/('sfFilterChain'),
> /object/('blogpostActions'), 'Success')
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfExecutionFilter.class.php/
> line 47 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 44. $timer->addTime();
> 45. $timer = sfTimerManager::getTimer(sprintf('View "%s"
> for "%s/%s"', $viewName, $actionInstance->getModuleName(),
> $actionInstance->getActionName()));
> 46.
>
> 47. $this->handleView($filterChain, $actionInstance,
> $viewName);
> 48.
>
> 49. $timer->addTime();
> 50. }
> * at *sfExecutionFilter->execute*(/object/('sfFilterChain'))
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfFilterChain.class.php/
> line 53 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 50. }
> 51.
>
> 52. // execute the next filter
> 53. $this->chain[$this->index]->execute($this);
> 54. }
> 55. }
> 56.
>
> * at *sfFilterChain->execute*()
> in
>
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfBasicSecurityFilter.class.php/
> line 72 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 69. }
> 70.
>
> 71. // the user has access, continue
> 72. $filterChain->execute();
> 73. }
> 74.
>
> 75. /**
> * at *sfBasicSecurityFilter->execute*(/object/('sfFilterChain'))
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfFilterChain.class.php/
> line 53 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 50. }
> 51.
>
> 52. // execute the next filter
> 53. $this->chain[$this->index]->execute($this);
> 54. }
> 55. }
> 56.
>
> * at *sfFilterChain->execute*()
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfRenderingFilter.class.php/
> line 33 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 30. public function execute($filterChain)
> 31. {
> 32. // execute next filter
> 33. $filterChain->execute();
> 34.
>
> 35. // get response object
> 36. $response = $this->context->getResponse();
> * at *sfRenderingFilter->execute*(/object/('sfFilterChain'))
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\filter\sfFilterChain.class.php/
> line 53 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 50. }
> 51.
>
> 52. // execute the next filter
> 53. $this->chain[$this->index]->execute($this);
> 54. }
> 55. }
> 56.
>
> * at *sfFilterChain->execute*()
> in
> /SF_ROOT_DIR\lib\vendor\symfony\lib\controller\sfController.class.php/
> line 229 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 226. }
> 227.
>
> 228. // process the filter chain
> 229. $filterChain->execute();
> 230. }
> 231. else
> 232. {
> * at *sfController->forward*('blogpost', 'edit')
> in
>
> /SF_ROOT_DIR\lib\vendor\symfony\lib\controller\sfFrontWebController.class.php/
> line 48 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 45. }
> 46.
>
> 47. // make the first request
> 48. $this->forward($moduleName, $actionName);
> 49. }
> 50. catch (sfException $e)
> 51. {
> * at *sfFrontWebController->dispatch*()
> in /SF_ROOT_DIR\lib\vendor\symfony\lib\util\sfContext.class.php/
> line 170 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
> 167. */
> 168. public function dispatch()
> 169. {
> 170. $this->getController()->dispatch();
> 171. }
> 172.
>
> 173. /**
> * at *sfContext->dispatch*()
> in /SF_ROOT_DIR\web\backend_dev.php/ line 13 ...
> <http://symfony.amslocal.com/backend_dev.php/blogpost/1/edit#>
>
> What am I missing please?
>
> Regards,
>
> Gregg
--
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en.