Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeolocationType: new options #290

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adding of the options entries for each field
  • Loading branch information
stephanecollot committed Aug 13, 2013
commit 2f26e48ef3c57c2f2c0dc5bbffc6165628d54d25
11 changes: 9 additions & 2 deletions Form/JQuery/Type/GeolocationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GeolocationType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('address', 'text');
$builder->add('address', 'text', $options['address']['options']);

foreach (array('latitude', 'longitude', 'locality', 'country') as $field) {
$option = $options[$field];
Expand All @@ -42,7 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$type = 'hidden';
}

$builder->add($field, $type);
$builder->add($field, $type, $option['options']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will generate a notice if someone sets "hidden" to true and doesn't define "options" index, see symfony/symfony#4833.

}
}

Expand All @@ -68,22 +68,29 @@ public function buildView(FormView $view, FormInterface $form, array $options)
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'address' => array(
'options' => array(),
),
'map' => false,
'latitude' => array(
'enabled' => false,
'hidden' => false,
'options' => array(),
),
'longitude' => array(
'enabled' => false,
'hidden' => false,
'options' => array(),
),
'locality' => array(
'enabled' => false,
'hidden' => false,
'options' => array(),
),
'country' => array(
'enabled' => false,
'hidden' => false,
'options' => array(),
),
));
}
Expand Down