Development

Changeset 13060

You must first sign up to be able to contribute.

Changeset 13060

Show
Ignore:
Timestamp:
11/17/08 12:52:11 (1 year ago)
Author:
fabien
Message:

[1.2] added a sfForm::getName() method (closes #4852)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/form/sfForm.class.php

    r12766 r13060  
    329329 
    330330  /** 
     331   * Returns the array name under which user data can retrieved. 
     332   * 
     333   * If the user data is not stored under an array, it returns null. 
     334   * 
     335   * @return string The name 
     336   */ 
     337  public function getName() 
     338  { 
     339    if ('%s' == $nameFormat = $this->widgetSchema->getNameFormat()) 
     340    { 
     341      return false; 
     342    } 
     343 
     344    return str_replace('[%s]', '', $nameFormat); 
     345  } 
     346 
     347  /** 
    331348   * Gets the error schema associated with the form. 
    332349   * 
  • branches/1.2/lib/generator/sfAdminGenerator.class.php

    r11349 r13060  
    739739  } 
    740740 
    741   public function getFormParameterName() 
    742   { 
    743     return str_replace('[%s]', '', $this->getFormObject()->getWidgetSchema()->getNameFormat()); 
    744   } 
    745  
    746741  /** 
    747742   * Retrieves all hidden fields in the widget schema 
  • branches/1.2/lib/generator/sfModelGenerator.class.php

    r12546 r13060  
    322322 
    323323  /** 
    324    * Gets the form parameter name. 
    325    * 
    326    * @param string The form parameter name 
    327    */ 
    328   public function getFormParameterName() 
    329   { 
    330     return str_replace('[%s]', '', $this->getFormObject()->getWidgetSchema()->getNameFormat()); 
    331   } 
    332  
    333   /** 
    334324   * Gets the HTML to add to the form tag if the form is multipart. 
    335325   * 
  • branches/1.2/test/unit/form/sfFormTest.php

    r12766 r13060  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(129, new lime_output_color()); 
     13$t = new lime_test(131, new lime_output_color()); 
    1414 
    1515class FormTest extends sfForm 
     
    7070$t->is($f->getDefault('_csrf_token'), $f->getCSRFToken('*mygreatsecret*'), '->getDefaults() keeps the CSRF token default value'); 
    7171sfForm::disableCSRFProtection(); 
     72 
     73// ->getName() 
     74$t->diag('->getName()'); 
     75$f = new FormTest(); 
     76$w = new sfWidgetFormSchema(); 
     77$f->setWidgetSchema($w); 
     78$t->is($f->getName(), null, '->getName() returns null if the name format is not an array'); 
     79$w->setNameFormat('foo[%s]'); 
     80$t->is($f->getName(), 'foo', '->getName() returns the name under which user data can be retrieved'); 
    7281 
    7382// ::enableCSRFProtection() ::disableCSRFProtection() ->isCSRFProtected() 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.