From 008278c7ecb7e12eb50f28b9cd66b10f547b2eb2 Mon Sep 17 00:00:00 2001 From: Yuchen Wang Date: Wed, 23 Nov 2011 16:15:51 -0500 Subject: [PATCH] CC-3093: SoundCloud preferences do not have email or password as required fields + firefox auto-fills the password field Fixing bug introduced by last commit...Should test more thoroughly next time... Fixed by creating and adding a custom validator that checks if the field is empty only when some other fields have specific values, in this case, when 'UploadToSoundcloudOption' has a value of '1'. --- .../forms/SoundcloudPreferences.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index 1597bbe19..8fe460c15 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -1,4 +1,5 @@ addElement('text', 'SoundCloudUser', array( 'class' => 'input_text', 'label' => 'SoundCloud Email', - 'required' => true, 'filters' => array('StringTrim'), 'autocomplete' => 'off', 'value' => Application_Model_Preference::GetSoundCloudUser(), 'decorators' => array( 'ViewHelper' + ), + + // By default, 'allowEmpty' is true. This means that our custom + // validators are going to be skipped if this field is empty, + // which is something we don't want + 'allowEmpty' => false, + 'validators' => array( + new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1')) ) )); @@ -56,12 +64,19 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm $this->addElement('password', 'SoundCloudPassword', array( 'class' => 'input_text', 'label' => 'SoundCloud Password', - 'required' => true, 'filters' => array('StringTrim'), 'autocomplete' => 'off', 'value' => Application_Model_Preference::GetSoundCloudPassword(), 'decorators' => array( 'ViewHelper' + ), + + // By default, 'allowEmpty' is true. This means that our custom + // validators are going to be skipped if this field is empty, + // which is something we don't want + 'allowEmpty' => false, + 'validators' => array( + new ConditionalNotEmpty(array('UploadToSoundcloudOption'=>'1')) ) ));