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