Skip to content

Commit

Permalink
added ReviewType approach
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Oct 9, 2012
1 parent d1470e7 commit fc3f1f1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions Admin/PageAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('General')
->add('review', 'review')
->add('parent', 'doctrine_phpcr_type_tree_model', array('choice_list' => array(), 'root_node' => $this->root))
->add('name', 'text', array('label' => 'Last URL part'))
->add('label', null, array('required' => false, 'label' => 'Menu label'))
Expand Down
35 changes: 35 additions & 0 deletions Form/ReviewType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Form;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;

use Symfony\Component\Form\AbstractType;

class ReviewType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function getParent()
{
return 'field';
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'review';
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'virtual' => true,
'required' => false,
'label' => 'Review'
));
}
}
4 changes: 4 additions & 0 deletions Resources/config/services/admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
</call>
</service>

<service id="symfony_cmf_simple_cms.admin.form_type.review" class="Symfony\Cmf\Bundle\SimpleCmsBundle\Form\ReviewType">
<tag name="form.type" alias="review"/>
</service>

</services>
</container>
6 changes: 6 additions & 0 deletions Resources/views/Form/fields.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% block review_widget %}
{% set document = form.vars.data %}
{% if document.path is defined %}

This comment has been minimized.

Copy link
@lsmith77

lsmith77 Oct 9, 2012

Author Member

@bschussek document is always null

This comment has been minimized.

Copy link
@webmozart

webmozart Oct 10, 2012

Ah, I think this is something that was not considered when implementing virtual forms. Right now, setData() is never called on a virtual form. Could you open a feature request please?

This comment has been minimized.

Copy link
@lsmith77

lsmith77 Oct 10, 2012

Author Member
<a href="{{ path(document) }}#{{ document.title }}">{{ document.title }}</a>
{% endif %}
{% endblock %}

0 comments on commit fc3f1f1

Please sign in to comment.