I have a drop down form element. Initially it starts out empty but it is populated with values via javascript after the user has made some interactions. Thats all working
Update in Validations.yml
Kindly update the Validation.yml file in the below format : setting the group names in the each field
password: - NotBlank: { message: Please enter password ,groups: [Default]}
Update in Form Type
/** * @param OptionsResolverInterface $resolver */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'RegistrationBundle\Entity\sf_members', 'validation_groups' => function(FormInterface $form){
$data = $form->getData();
$member_id = $data->getMemberId();// Block of code; // starts Here :
if( condition == 'edit profile') { return array('edit'); } else { return array('Default'); } },
Update in Entity
/**
* @var string
*
* @ORM\Column(name="password", type="text")
* @Assert\Regex(
* pattern="/(?i)^(?=.[a-zA-Z])(?=.\d).{8,}$/",
* match=true,
* message="Your password must be at least 8 characters, including at least one number and one letter",
* groups={"Default","edit"}
* )
*/
private $password;