Skip to content

Instantly share code, notes, and snippets.

@euskadi31
Created September 15, 2012 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save euskadi31/3728134 to your computer and use it in GitHub Desktop.
Save euskadi31/3728134 to your computer and use it in GitHub Desktop.
I have 2 select one country and the other choice (admin1code) and it is updated based on ajax country, it worked very well in 2.0
since updating to 2.1 I get this error on admin1code "This value is not valid.".
I think the isValid checks that the data correspond to the content posted or select the select is empty because it depends on the country.
in my Entity I do not have this field validator (admin1code).
------------- French ---------------
j'ai 2 select un country et l'autre choice (admin1code) et ce dernier est mis à jour en ajax en fonction du country, ça marchait très bien en 2.0
depuis la mise à jour en 2.1 j'ai cette erreur sur le admin1code "This value is not valid.".
je pense que le isValid vérifie que les données postées correspondent au contenu du select or ce select est vide car il dépend du country.
dans mon Entity je n'ai pas de validateur sur ce champ (admin1code).
<?php
namespace My\FrontBundle\Form\Type\Register;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class AgencyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', 'text', array(
'label' => 'Company/Organization'
));
$builder->add('address', 'text', array(
'label' => 'Street Address'
));
$builder->add('zipcode', 'text', array(
'label' => 'ZIP/Postal Code'
));
$builder->add('city', 'text', array(
'label' => 'City'
));
$builder->add('country', 'country', array(
'label' => 'Country',
'preferred_choices' => array('US', 'DE', 'FR', 'GB', 'JP')
));
$builder->add('admin1code', 'choice', array(
'label' => 'State/Province',
'required' => true,
'empty_value' => 'Other or N/A',
'empty_data' => '',
'attr' => array(
'disabled' => 'disabled'
)
));
$builder->add('phone', 'text', array(
'label' => 'Phone'
));
}
public function getName()
{
return 'registerAgency';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment