In this fork there is a method to add an array of options to both registration and profile forms. Testing the method is, however, currently outside of my skill set. I'd appreciate some pointers. Functionally these modifications satisfy the requirement of adding options to templates.
An example of how the method is used in a form:
$builder->addEventListener(FormEvents::PRE_SET_DATA,
function (FormEvent $event) {
$form = $event->getForm();
if ($this->options['skill_required']) {
$form->add('skills', 'skills');
};
if ($this->options['focus_required']) {
$form->add('focuses', 'focuses');
};
});
public function getFormType($name)
{
$class = $this->getClass();
$className = $this->conf[$class][$name]['form']['type'];
$options = $this->conf[$class]['options']; //added
if (!class_exists($className)) {
throw new \InvalidArgumentException(sprintf('UserDiscriminator, error getting form type : "%s" not found', $className));
}
$type = new $className($class, $options); //parameter added
return $type;
}
copy in FOSUserBundle Registration & Profile forms and modify each:
private $class;
protected $options;
/**
* @param string $class The User class name
*/
public function __construct($class, $options = null)
{
$this->class = $class;
$this->options = $options;
}
In this fork there is a method to add an array of options to both registration and profile forms. Testing the method is, however, currently outside of my skill set. I'd appreciate some pointers. Functionally these modifications satisfy the requirement of adding options to templates.
An example of how the method is used in a form:
Here's an outline of the method:
options:
topugx_multi_user: user:
. Example:options
parameter toPUGX\MultiUserBundle\DependencyInjection\Configuration
:PUGX\MultiUserBundle\DependencyInjection\Compiler\OverrideServiceCompilerPass
:PUGX\MultiUserBundle\Model\UserDiscriminator
:and