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'.
This commit is contained in:
Yuchen Wang 2011-11-23 16:15:51 -05:00
parent d3df4b14d2
commit 008278c7ec

View file

@ -1,4 +1,5 @@
<?php <?php
require_once 'customvalidators/ConditionalNotEmpty.php';
class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
{ {
@ -43,12 +44,19 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm
$this->addElement('text', 'SoundCloudUser', array( $this->addElement('text', 'SoundCloudUser', array(
'class' => 'input_text', 'class' => 'input_text',
'label' => 'SoundCloud Email', 'label' => 'SoundCloud Email',
'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'autocomplete' => 'off', 'autocomplete' => 'off',
'value' => Application_Model_Preference::GetSoundCloudUser(), 'value' => Application_Model_Preference::GetSoundCloudUser(),
'decorators' => array( 'decorators' => array(
'ViewHelper' '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( $this->addElement('password', 'SoundCloudPassword', array(
'class' => 'input_text', 'class' => 'input_text',
'label' => 'SoundCloud Password', 'label' => 'SoundCloud Password',
'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'autocomplete' => 'off', 'autocomplete' => 'off',
'value' => Application_Model_Preference::GetSoundCloudPassword(), 'value' => Application_Model_Preference::GetSoundCloudPassword(),
'decorators' => array( 'decorators' => array(
'ViewHelper' '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'))
) )
)); ));