diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index d576822a9..0e3bedce5 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -127,7 +127,7 @@ class PersonType extends AbstractType ->add('mobilenumber', TelType::class, array('required' => false)) ->add('acceptSMS', CheckboxType::class, array( 'value' => false, - 'required' => true //TODO required only if mobilenumber is filled + 'required' => true )); } @@ -149,7 +149,7 @@ class PersonType extends AbstractType if ($this->config['email'] === 'visible') { $builder ->add('email', EmailType::class, array('required' => false)) - ->add('acceptEmail', CheckboxType::class, array('required' => false));//TODO visible only if email is filled + ->add('acceptEmail', CheckboxType::class, array('required' => false)); } if ($this->config['country_of_birth'] === 'visible') { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php index 232c838bb..bdd31e899 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php @@ -24,8 +24,7 @@ class GenderType extends AbstractType { $a = array( Person::MALE_GENDER => Person::MALE_GENDER, Person::FEMALE_GENDER => Person::FEMALE_GENDER, - Person::BOTH_GENDER => Person::BOTH_GENDER, - Person::NO_INFORMATION => Person::NO_INFORMATION + Person::BOTH_GENDER => Person::BOTH_GENDER ); $resolver->setDefaults(array( diff --git a/src/Bundle/ChillPersonBundle/Resources/public/js/person.js b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js new file mode 100644 index 000000000..6ebd8d7cc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js @@ -0,0 +1,38 @@ +import { ShowHide } from 'ShowHide/show_hide.js'; + +const personEmail = document.getElementById("personEmail"); +const personAcceptEmail = document.getElementById("personAcceptEmail"); +const personPhoneNumber = document.getElementById("personPhoneNumber"); +const personAcceptSMS = document.getElementById("personAcceptSMS"); + +new ShowHide({ + froms: [personEmail], + container: [personAcceptEmail], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('input').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'input' +}); + +new ShowHide({ + froms: [personPhoneNumber], + container: [personAcceptSMS], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('input').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'input' +}); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig index 66e1cb6e6..95b4e6f62 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig @@ -82,15 +82,24 @@