PHP Class sfFormPropel, sfPropelORMPlugin

Author: Fabien Potencier ([email protected])
Inheritance: extends sfForm
Exibir arquivo Open project: propelorm/sfPropelORMPlugin Class Usage Examples

Protected Properties

Property Type Description
$deleteField string Name of the field used for deletion.
$optionalForms array[sfForm] List of forms that can be added by the user

Public Methods

Method Description
__clone ( )
__construct ( $object = null, $options = [], $CSRFSecret = null ) Constructor.
addOptionalForms ( $taintedValues = null )
bind ( array $taintedValues = null, array $taintedFiles = null ) Binds the form with input values.
embedI18n ( array $cultures, string $decorator = null ) Embeds i18n objects into the current form.
embedRelation ( string $relationName, array $options = [] ) : sfPropelForm Embed a Collection form based on a Relation into this form.
getConnection ( ) : PropelPDO
getDeleteField ( )
getEmptyRelatedForm ( string $relationName, array $options = [] ) : sfFormPropel Get an empty Propel form based on a Relation of the current form's model.
getI18nFormClass ( ) : string Returns the name of the i18n form class.
getI18nModelName ( ) : string Returns the name of the i18n model.
getPeer ( ) : string Get the name of the Peer class of the form's model, e.g. 'AuthorPeer'
getRelationForm ( string $relationName, array $options = [] ) : sfFormPropelCollection Get a Collection form based on a Relation of the current form's model.
hasDeleteField ( )
isI18n ( ) : boolean Returns true if the current form has some associated i18n objects.
mergeForm ( sfForm $form ) Overrides sfForm::mergeForm() to also merge embedded forms Allows autosave of merged collections
mergeRelation ( string $relationName, array $options = [] ) : sfPropelForm Merge a Collection form based on a Relation into this form.
processValues ( $values ) Processes cleaned up values with user defined methods.
saveEmbeddedForms ( mixed $con = null, array $forms = null ) Saves embedded form objects.
setDeleteField ( $fieldName )
setDeleteWidget ( string $name, sfWidgetForm $widget ) : sfPropelForm Adds a widget to the form, and declare this widget as the delete control.

Protected Methods

Method Description
addEmptyRelationForm ( string $relationName, sfFormPropelCollection $relationForm, string $emptyName, string $prefix, array $options = [] ) Adds an empty Propel form based on a Relation of the current form's model to a collection form.
doSave ( mixed $con = null ) Updates and saves the current object.
doUpdateObject ( array $values ) Updates the values of the object with the cleaned up values.
getRelationFields ( $relationMap )
getRelationMap ( $relationName )
processUploadedFile ( string $field, string $filename = null, array $values = null ) : string Saves the uploaded file for the given field.
removeFile ( string $field ) Removes the current file for the field.
saveFile ( string $field, string $filename = null, sfValidatedFile $file = null ) : string Saves the current file for the field.
updateDefaultsFromObject ( ) Updates the default values of the form with the current values of the current object.

Method Details

__clone() public method

public __clone ( )

__construct() public method

Constructor.
See also: sfForm
public __construct ( $object = null, $options = [], $CSRFSecret = null )

addEmptyRelationForm() protected method

Available options: - add_empty: Whether to allow the user to add new objects to the collection. Defaults to true - max_additions: The maximum number of related objects that can be added. Defaults to 0 (no limit) - add_link: Text of the JS link that triggers the addition of the empty form. Defaults to 'Add new' - empty_decorator: decorator for the empty form
protected addEmptyRelationForm ( string $relationName, sfFormPropelCollection $relationForm, string $emptyName, string $prefix, array $options = [] )
$relationName string The name of a relation of the current Model, e.g. 'Book'
$relationForm sfFormPropelCollection The form to augment
$emptyName string The name of the empty form to add
$prefix string The prefix to ad to the empty name to form the key to the optional forms array
$options array An array of options

addOptionalForms() public method

public addOptionalForms ( $taintedValues = null )

bind() public method

It triggers the validator schema validation.
public bind ( array $taintedValues = null, array $taintedFiles = null )
$taintedValues array An array of input values
$taintedFiles array An array of uploaded files (in the $_FILES or $_GET format)

doSave() protected method

Updates and saves the current object.
See also: sfFormObject If you want to add some logic before saving or save other associated objects, this is the method to override.
protected doSave ( mixed $con = null )
$con mixed An optional connection object

doUpdateObject() protected method

If you want to add some logic before updating or update other associated objects, this is the method to override.
See also: sfFormObject
protected doUpdateObject ( array $values )
$values array An array of values

embedI18n() public method

Embeds i18n objects into the current form.
public embedI18n ( array $cultures, string $decorator = null )
$cultures array An array of cultures
$decorator string A HTML decorator for the embedded form

embedRelation() public method

Available options: - title: The title of the collection form once embedded. Defaults to the relation name. - decorator: The decorator for the sfWidgetFormSchemaDecorator - add_empty: Whether to allow the user to add new objects to the collection. Defaults to true - empty_label: Label showed to create a new related item. By default is new + name of the relation Additional options are passed to sfFromPropel::getRelationForm()
public embedRelation ( string $relationName, array $options = [] ) : sfPropelForm
$relationName string The name of a relation of the current Model, e.g. 'Book'
$options array An array of options
return sfPropelForm The current form instance

getConnection() public method

See also: sfFormObject
public getConnection ( ) : PropelPDO
return PropelPDO

getDeleteField() public method

public getDeleteField ( )

getEmptyRelatedForm() public method

Available options: - embedded_form_class: The class of the form to return - empty_label: The label of the empty form
public getEmptyRelatedForm ( string $relationName, array $options = [] ) : sfFormPropel
$relationName string The name of a relation of the current Model, e.g. 'Book'
$options array An array of options
return sfFormPropel A Propel form instance

getI18nFormClass() public method

Returns the name of the i18n form class.
public getI18nFormClass ( ) : string
return string The name of the i18n form class

getI18nModelName() public method

Returns the name of the i18n model.
public getI18nModelName ( ) : string
return string The name of the i18n model

getPeer() public method

Get the name of the Peer class of the form's model, e.g. 'AuthorPeer'
public getPeer ( ) : string
return string A Peer class name

getRelationFields() protected method

protected getRelationFields ( $relationMap )

getRelationForm() public method

Available options: - hide_on_new: If true, returns null for new objects. Defaults to false. - collection_form_class: class of the collection form to return. Defaults to sfFormPropelCollection. - criteria: Optional criteria to filter related objects Additional options are passed to sfFormPropelCollection::__construct()
public getRelationForm ( string $relationName, array $options = [] ) : sfFormPropelCollection
$relationName string The name of a relation of the current Model, e.g. 'Book'
$options array An array of options
return sfFormPropelCollection A form collection instance

getRelationMap() protected method

protected getRelationMap ( $relationName )

hasDeleteField() public method

public hasDeleteField ( )

isI18n() public method

Returns true if the current form has some associated i18n objects.
public isI18n ( ) : boolean
return boolean true if the current form has some associated i18n objects, false otherwise

mergeForm() public method

Overrides sfForm::mergeForm() to also merge embedded forms Allows autosave of merged collections
public mergeForm ( sfForm $form )
$form sfForm The sfForm instance to merge with current form

mergeRelation() public method

Available options: - add_empty: Whether to allow the user to add new objects to the collection. Defaults to true Additional options are passed to sfFromPropel::getRelationForm()
public mergeRelation ( string $relationName, array $options = [] ) : sfPropelForm
$relationName string The name of a relation of the current Model, e.g. 'Book'
$options array An array of options
return sfPropelForm The current form instance

processUploadedFile() protected method

Saves the uploaded file for the given field.
protected processUploadedFile ( string $field, string $filename = null, array $values = null ) : string
$field string The field name
$filename string The file name of the file to save
$values array An array of values
return string The filename used to save the file

processValues() public method

To process a value before it is used by the updateObject() method, you need to define an updateXXXColumn() method where XXX is the PHP name of the column. The method must return the processed value or false to remove the value from the array of cleaned up values.
See also: sfFormObject
public processValues ( $values )

removeFile() protected method

Removes the current file for the field.
protected removeFile ( string $field )
$field string The field name

saveEmbeddedForms() public method

Saves embedded form objects.
See also: sfFormObject
public saveEmbeddedForms ( mixed $con = null, array $forms = null )
$con mixed An optional connection object
$forms array An array of forms

saveFile() protected method

Saves the current file for the field.
protected saveFile ( string $field, string $filename = null, sfValidatedFile $file = null ) : string
$field string The field name
$filename string The file name of the file to save
$file sfValidatedFile The validated file to save
return string The filename used to save the file

setDeleteField() public method

public setDeleteField ( $fieldName )

setDeleteWidget() public method

If the bound widget value is true, then the related object will be deleted
public setDeleteWidget ( string $name, sfWidgetForm $widget ) : sfPropelForm
$name string The field name
$widget sfWidgetForm The widget
return sfPropelForm The current form instance

updateDefaultsFromObject() protected method

Updates the default values of the form with the current values of the current object.
protected updateDefaultsFromObject ( )

Property Details

$deleteField protected_oe property

Name of the field used for deletion.
protected string $deleteField
return string

$optionalForms protected_oe property

List of forms that can be added by the user
protected array[sfForm] $optionalForms
return array[sfForm]