All pastes #2109439 Raw Edit

Stuff

public php v1 · immutable
#2109439 ·published 2012-02-03 17:09 UTC
rendered paste body
<?phpnamespace Politistream\CoreBundle\Form;use Symfony\Component\Form\AbstractType;use Symfony\Component\Form\FormBuilder;use Politistream\CoreBundle\Component\Profile\ProfileComponentFactory;class ProfileRuleType extends AbstractType{  /**   *   * @var ProfileComponentFactory $componentFactory   */  protected $componentFactory;  public function __construct(ProfileComponentFactory $factory)  {    $this->componentFactory = $factory;  }  public function buildForm(FormBuilder $builder, array $options)  {    $components = $this->componentFactory->getComponents();    $choices = array();    $fieldChoices = array();    foreach ($components as $k => $c)    {      $choices[$k] = ucwords(str_replace('_', ' ', $k));      $fieldChoices[$k] = $this->componentFactory->getRuleFields($k);    }    $builder            ->add('component', 'choice', array('choices' => $choices))            ->add('field', 'chained_choice', array('choices' => $fieldChoices, 'link' => 'component'))            ->add('rule', 'rule')    ;  }  public function getName()  {    return 'politistream_corebundle_profileruletype';  }  public function getDefaultOptions(array $options)  {    return array(        'data_class' => 'Politistream\CoreBundle\Entity\ProfileRule',    );  }}