This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Form/FormInterface.php

251 lines
5.5 KiB
PHP
Raw Normal View History

<?php
2010-10-02 11:38:11 +01:00
/*
* This file is part of the Symfony package.
2010-10-02 11:38:11 +01:00
*
* (c) Fabien Potencier <fabien@symfony.com>
2010-10-02 11:38:11 +01:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
2010-10-02 11:38:11 +01:00
*/
namespace Symfony\Component\Form;
/**
* A form group bundling multiple form forms
*
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
*/
interface FormInterface extends \ArrayAccess, \Traversable, \Countable
{
/**
* Sets the parent form.
*
2011-05-10 17:23:58 +01:00
* @param FormInterface $parent The parent form
*/
function setParent(FormInterface $parent = null);
/**
* Returns the parent form.
*
2011-05-10 17:23:58 +01:00
* @return FormInterface The parent form
*/
function getParent();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the form has a parent.
*
* @return Boolean
*/
function hasParent();
/**
* Adds a child to the form.
*
* @param FormInterface $child The FormInterface to add as a child
*/
function add(FormInterface $child);
/**
* Returns the child with the given name.
*
* @param string $name The name of the child
*
* @return FormInterface The child form
*/
function get($name);
2011-05-10 14:32:14 +01:00
/**
* Returns whether a child with the given name exists.
*
* @param string $name The name of the child
2011-05-10 14:32:14 +01:00
*
* @return Boolean
*/
function has($name);
2011-05-10 14:32:14 +01:00
/**
* Removes a child from the form.
*
* @param string $name The name of the child to remove
*/
function remove($name);
2011-05-10 14:32:14 +01:00
/**
* Returns all children in this group.
*
2011-05-10 17:23:58 +01:00
* @return array An array of FormInterface instances
2011-05-10 14:32:14 +01:00
*/
function getChildren();
2011-05-10 14:32:14 +01:00
/**
* Return whether the form has children.
*
* @return Boolean
*/
function hasChildren();
2011-05-10 14:32:14 +01:00
/**
* Returns all errors.
*
2011-05-10 17:23:58 +01:00
* @return array An array of FormError instances that occurred during binding
2011-05-10 14:32:14 +01:00
*/
2011-03-22 22:20:14 +00:00
function getErrors();
2011-05-10 14:32:14 +01:00
/**
* Updates the field with default data.
*
* @param array $appData The data formatted as expected for the underlying object
*
* @return Form The current form
*/
function setData($appData);
2011-05-10 14:32:14 +01:00
/**
* Returns the data in the format needed for the underlying object.
*
* @return mixed
*/
2011-03-22 22:20:14 +00:00
function getData();
2011-05-10 14:32:14 +01:00
/**
* Returns the normalized data of the field.
*
* @return mixed When the field is not bound, the default data is returned.
* When the field is bound, the normalized bound data is
* returned if the field is valid, null otherwise.
*/
function getNormData();
2011-05-10 14:32:14 +01:00
/**
* Returns the data transformed by the value transformer.
*
* @return string
*/
2011-03-22 22:20:14 +00:00
function getClientData();
2011-05-10 14:32:14 +01:00
/**
* Returns the extra data.
*
* @return array The bound data which do not belong to a child
*/
function getExtraData();
/**
* Returns whether the field is bound.
*
* @return Boolean true if the form is bound to input values, false otherwise
*/
2011-03-22 22:20:14 +00:00
function isBound();
2011-05-10 14:32:14 +01:00
/**
* Returns the supported types.
*
* @return array An array of FormTypeInterface
*/
function getTypes();
/**
* Returns the name by which the form is identified in forms.
*
* @return string The name of the form.
*/
function getName();
/**
2011-05-10 14:32:14 +01:00
* Adds an error to this form.
*
* @param FormError $error
*/
function addError(FormError $error);
/**
* Returns whether the form is valid.
*
* @return Boolean
*/
function isValid();
/**
* Returns whether the form is required to be filled out.
*
* If the form has a parent and the parent is not required, this method
* will always return false. Otherwise the value set with setRequired()
* is returned.
*
* @return Boolean
*/
function isRequired();
/**
* Returns whether this form is disabled.
*
* The content of a disabled form is displayed, but not allowed to be
* modified. The validation of modified disabled forms should fail.
*
* Fields whose parents are disabled are considered disabled regardless of
* their own state.
*
* @return Boolean
*/
function isDisabled();
/**
2011-05-10 14:32:14 +01:00
* Returns whether the form is empty.
*
2011-04-27 06:25:26 +01:00
* @return Boolean
*/
function isEmpty();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the data in the different formats is synchronized.
*
* @return Boolean
*/
function isSynchronized();
/**
2011-05-10 14:32:14 +01:00
* Writes data into the form.
*
2011-05-10 14:32:14 +01:00
* @param mixed $data The data
*/
function bind($data);
2011-05-10 14:32:14 +01:00
/**
* Returns whether the form has an attribute with the given name.
*
* @param string $name The name of the attribute
*/
function hasAttribute($name);
2011-05-10 14:32:14 +01:00
/**
* Returns the value of the attributes with the given name.
*
* @param string $name The name of the attribute
*/
function getAttribute($name);
2011-05-10 14:32:14 +01:00
/**
* Returns the root of the form tree.
*
* @return FormInterface The root of the tree
*/
function getRoot();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the field is the root of the form tree.
*
* @return Boolean
*/
function isRoot();
2011-05-10 14:32:14 +01:00
/**
* Creates a view.
*
* @param FormView $parent The parent view
*
* @return FormView The view
*/
function createView(FormView $parent = null);
}