Development

Changeset 6113

You must first sign up to be able to contribute.

Changeset 6113

Show
Ignore:
Timestamp:
11/20/07 11:07:00 (1 year ago)
Author:
fabien
Message:

added a always_render_empty option to sfWidgetFormInputPassword

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/widget/sfWidgetFormInputPassword.class.php

    r5937 r6113  
    2020{ 
    2121  /** 
     22   * Configures the current widget. 
     23   * 
     24   * Available options: 
     25   * 
     26   *  * always_render_empty: true if you want the input value to be always empty when rendering (true by default) 
     27   * 
    2228   * @see sfWidgetFormInput 
    2329   */ 
     
    2632    parent::configure($options, $attributes); 
    2733 
     34    $this->addOption('always_render_empty', true); 
     35 
    2836    $this->setOption('type', 'password'); 
    2937  } 
     38 
     39  /** 
     40   * @see sfWidgetForm 
     41   */ 
     42  public function render($name, $value = null, $attributes = array(), $errors = array()) 
     43  { 
     44    return parent::render($name, $this->getOption('always_render_empty') ? null : $value, $attributes, $errors); 
     45  } 
    3046} 
  • trunk/test/unit/widget/sfWidgetFormInputPasswordTest.php

    r5937 r6113  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(1, new lime_output_color()); 
     13$t = new lime_test(3, new lime_output_color()); 
    1414 
    1515$w = new sfWidgetFormInputPassword(); 
     
    1818$t->diag('->render()'); 
    1919$t->is($w->render('foo'), '<input type="password" name="foo" id="foo" />', '->render() renders the widget as HTML'); 
     20 
     21$t->is($w->render('foo', 'bar'), '<input type="password" name="foo" id="foo" />', '->render() renders the widget as HTML'); 
     22 
     23$w->setOption('always_render_empty', false); 
     24$t->is($w->render('foo', 'bar'), '<input type="password" name="foo" value="bar" id="foo" />', '->render() renders the widget as HTML');