mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Revert geo id field name && allow dash in field name in configuration file
This commit is contained in:

committed by
Romain Neutron

parent
45fe839cfe
commit
10f8569dde
@@ -13,7 +13,6 @@ namespace Alchemy\Phrasea\Core\Provider;
|
||||
|
||||
use Silex\Application;
|
||||
use Silex\ServiceProviderInterface;
|
||||
use Alchemy\Phrasea\Utilities\String\Camelizer;
|
||||
|
||||
// write tests
|
||||
class RegistrationServiceProvider implements ServiceProviderInterface
|
||||
@@ -22,16 +21,10 @@ class RegistrationServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
$app['registration.fields'] = $app->share(function (Application $app){
|
||||
if($app['phraseanet.configuration']->has('registration-fields')) {
|
||||
$camelizer = new Camelizer();
|
||||
|
||||
return array_map(function($field) use ($camelizer) {
|
||||
$field['name'] = $camelizer->camelize($field['name'], '-');
|
||||
|
||||
return $field;
|
||||
}, $app['phraseanet.configuration']->get('registration-fields'));
|
||||
} else {
|
||||
return array();
|
||||
return $app['phraseanet.configuration']->get('registration-fields');
|
||||
}
|
||||
|
||||
return array();
|
||||
});
|
||||
|
||||
$app['registration.optional-fields'] = $app->share(function (Application $app) {
|
||||
@@ -49,11 +42,11 @@ class RegistrationServiceProvider implements ServiceProviderInterface
|
||||
'2' => _('admin::compte-utilisateur:sexe: monsieur'),
|
||||
)
|
||||
),
|
||||
'firstName' => array(
|
||||
'first-name' => array(
|
||||
'label' => _('admin::compte-utilisateur prenom'),
|
||||
'type' => 'text',
|
||||
),
|
||||
'lastName' => array(
|
||||
'last-name' => array(
|
||||
'label' => _('admin::compte-utilisateur nom'),
|
||||
'type' => 'text',
|
||||
),
|
||||
@@ -61,11 +54,11 @@ class RegistrationServiceProvider implements ServiceProviderInterface
|
||||
'label' => _('admin::compte-utilisateur adresse'),
|
||||
'type' => 'textarea',
|
||||
),
|
||||
'zipCode' => array(
|
||||
'zip-code' => array(
|
||||
'label' => _('admin::compte-utilisateur code postal'),
|
||||
'type' => 'text',
|
||||
),
|
||||
'city' => array(
|
||||
'geoname-id' => array(
|
||||
'label' => _('admin::compte-utilisateur ville'),
|
||||
'type' => new \Alchemy\Phrasea\Form\Type\GeonameType(),
|
||||
),
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Alchemy\Phrasea\Form\Login;
|
||||
|
||||
use Alchemy\Phrasea\Utilities\String\Camelizer;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
@@ -20,11 +21,13 @@ class PhraseaRegisterForm extends AbstractType
|
||||
{
|
||||
private $available;
|
||||
private $params;
|
||||
private $camelizer;
|
||||
|
||||
public function __construct(array $available, array $params = array())
|
||||
public function __construct(array $available, array $params = array(), Camelizer $camelizer = null)
|
||||
{
|
||||
$this->available = $available;
|
||||
$this->params = $params;
|
||||
$this->camelizer = $camelizer ?: new Camelizer();
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
@@ -62,7 +65,7 @@ class PhraseaRegisterForm extends AbstractType
|
||||
$name = $param['name'];
|
||||
if (isset($this->available[$name])) {
|
||||
$builder->add(
|
||||
$name,
|
||||
$this->camelizer->camelize($name, '-'),
|
||||
$this->getType($name),
|
||||
array(
|
||||
'label' => $this->getLabel($name),
|
||||
|
@@ -59,12 +59,14 @@
|
||||
</div>
|
||||
|
||||
{% for field in app['registration.fields'] %}
|
||||
{% set fieldName = field['name'] %}
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
{{ auth_macro.fieldInput(attribute(form, field['name']), "registerForm") }}
|
||||
{% set name = field['name'] %}
|
||||
{% if name in app['registration.optional-fields']|keys %}
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
{{ auth_macro.fieldInput(attribute(form, name|camelize), "registerForm") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<div class="row-fluid">
|
||||
|
Reference in New Issue
Block a user