Development

Changeset 10476

You must first sign up to be able to contribute.

Changeset 10476

Show
Ignore:
Timestamp:
07/25/08 20:40:09 (4 months ago)
Author:
Kris.Wallsmith
Message:

sfFormtasticPlugin: added sfFormtastic::bindToRequest() method that automagically uses sfContext to get what it needs based on name format

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfFormtasticPlugin/trunk/lib/form/sfFormtastic.class.php

    r10216 r10476  
    2020   
    2121  /** 
     22   * Bind to parameters from the symfony request object, based on name format. 
     23   *  
     24   * @throws LogicException If the name format is not recognized 
     25   */ 
     26  public function bindToRequest() 
     27  { 
     28    $request = sfContext::getInstance()->getRequest(); 
     29     
     30    if ('%s' == $nameFormat = $this->widgetSchema->getNameFormat()) 
     31    { 
     32      $this->bind($request->isMethod('post') ? $request->getPostParameters() : $request->getGetParameters(), $request->getFiles()); 
     33    } 
     34    elseif ('[%s]' == substr($nameFormat, -4)) 
     35    { 
     36      $this->bind($request->getParameter(substr($nameFormat, 0, -4)), $request->getFiles()); 
     37    } 
     38    else 
     39    { 
     40      throw new LogicException(sprintf('%s cannot understand the name format "%s"', __METHOD__, $nameFormat)); 
     41    } 
     42  } 
     43   
     44  /** 
    2245   * @see sfForm 
    2346   */