PHP Class sfFormPropel, sfPropelORMPlugin

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

Protected Properties

Свойство Type Description
$deleteField string Name of the field used for deletion.
$optionalForms array[sfForm] List of forms that can be added by the user

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

public __clone ( )

__construct() public méthode

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

addEmptyRelationForm() protected méthode

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 méthode

public addOptionalForms ( $taintedValues = null )

bind() public méthode

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 méthode

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 méthode

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 méthode

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 méthode

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
Résultat sfPropelForm The current form instance

getConnection() public méthode

See also: sfFormObject
public getConnection ( ) : PropelPDO
Résultat PropelPDO

getDeleteField() public méthode

public getDeleteField ( )

getEmptyRelatedForm() public méthode

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
Résultat sfFormPropel A Propel form instance

getI18nFormClass() public méthode

Returns the name of the i18n form class.
public getI18nFormClass ( ) : string
Résultat string The name of the i18n form class

getI18nModelName() public méthode

Returns the name of the i18n model.
public getI18nModelName ( ) : string
Résultat string The name of the i18n model

getPeer() public méthode

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

getRelationFields() protected méthode

protected getRelationFields ( $relationMap )

getRelationForm() public méthode

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
Résultat sfFormPropelCollection A form collection instance

getRelationMap() protected méthode

protected getRelationMap ( $relationName )

hasDeleteField() public méthode

public hasDeleteField ( )

isI18n() public méthode

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

mergeForm() public méthode

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 méthode

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
Résultat sfPropelForm The current form instance

processUploadedFile() protected méthode

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
Résultat string The filename used to save the file

processValues() public méthode

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 méthode

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

saveEmbeddedForms() public méthode

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 méthode

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
Résultat string The filename used to save the file

setDeleteField() public méthode

public setDeleteField ( $fieldName )

setDeleteWidget() public méthode

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
Résultat sfPropelForm The current form instance

updateDefaultsFromObject() protected méthode

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
Résultat string

$optionalForms protected_oe property

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