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

247 lines
5.6 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
*
2012-05-26 08:48:33 +01:00
* @author Bernhard Schussek <bschussek@gmail.com>
*/
interface FormInterface extends \ArrayAccess, \Traversable, \Countable
{
/**
* Sets the parent form.
*
* @param FormInterface $parent The parent form
*
* @return FormInterface The form instance
*/
2012-07-09 13:50:58 +01:00
public function setParent(FormInterface $parent = null);
/**
* Returns the parent form.
*
2011-05-10 17:23:58 +01:00
* @return FormInterface The parent form
*/
2012-07-09 13:50:58 +01:00
public function getParent();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the form has a parent.
*
* @return Boolean
*/
2012-07-09 13:50:58 +01:00
public function hasParent();
2011-05-10 14:32:14 +01:00
/**
* Adds a child to the form.
*
* @param FormInterface $child The FormInterface to add as a child
*
* @return FormInterface The form instance
2011-05-10 14:32:14 +01:00
*/
2012-07-09 13:50:58 +01:00
public function add(FormInterface $child);
/**
* Returns the child with the given name.
*
* @param string $name The name of the child
*
* @return FormInterface The child form
*/
2012-07-09 13:50:58 +01:00
public 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
*/
2012-07-09 13:50:58 +01:00
public 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
*
* @return FormInterface The form instance
2011-05-10 14:32:14 +01:00
*/
2012-07-09 13:50:58 +01:00
public 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
*/
2012-07-09 13:50:58 +01:00
public function all();
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
*/
2012-07-09 13:50:58 +01:00
public function getErrors();
2011-03-22 22:20:14 +00:00
2011-05-10 14:32:14 +01:00
/**
* Updates the field with default data.
*
* @param array $modelData The data formatted as expected for the underlying object
2011-05-10 14:32:14 +01:00
*
* @return FormInterface The form instance
2011-05-10 14:32:14 +01:00
*/
2012-07-09 13:50:58 +01:00
public function setData($modelData);
2011-05-10 14:32:14 +01:00
/**
* Returns the data in the format needed for the underlying object.
*
* @return mixed
*/
2012-07-09 13:50:58 +01:00
public function getData();
2011-03-22 22:20:14 +00:00
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.
2011-05-10 14:32:14 +01:00
* When the field is bound, the normalized bound data is
* returned if the field is valid, null otherwise.
*/
2012-07-09 13:50:58 +01:00
public function getNormData();
2011-05-10 14:32:14 +01:00
/**
* Returns the data transformed by the value transformer.
*
* @return string
*/
2012-07-09 13:50:58 +01:00
public function getViewData();
2011-03-22 22:20:14 +00:00
2011-05-10 14:32:14 +01:00
/**
* Returns the extra data.
*
* @return array The bound data which do not belong to a child
*/
2012-07-09 13:50:58 +01:00
public function getExtraData();
2011-05-10 14:32:14 +01:00
/**
* Returns the form's configuration.
2011-05-10 14:32:14 +01:00
*
* @return FormConfigInterface The configuration.
2011-05-10 14:32:14 +01:00
*/
2012-07-09 13:50:58 +01:00
public function getConfig();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the field is bound.
2011-05-10 14:32:14 +01:00
*
* @return Boolean true if the form is bound to input values, false otherwise
2011-05-10 14:32:14 +01:00
*/
2012-07-09 13:50:58 +01:00
public function isBound();
/**
* Returns the name by which the form is identified in forms.
*
* @return string The name of the form.
*/
2012-07-09 13:50:58 +01:00
public function getName();
/**
* Returns the property path that the form is mapped to.
*
* @return Util\PropertyPath The property path.
*/
2012-07-09 13:50:58 +01:00
public function getPropertyPath();
/**
2011-05-10 14:32:14 +01:00
* Adds an error to this form.
*
* @param FormError $error
*
* @return FormInterface The form instance
*/
2012-07-09 13:50:58 +01:00
public function addError(FormError $error);
/**
* Returns whether the form is valid.
*
* @return Boolean
*/
2012-07-09 13:50:58 +01:00
public 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
*/
2012-07-09 13:50:58 +01:00
public 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.
*
* Forms whose parents are disabled are considered disabled regardless of
* their own state.
*
* @return Boolean
*/
2012-07-09 13:50:58 +01:00
public 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
*/
2012-07-09 13:50:58 +01:00
public function isEmpty();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the data in the different formats is synchronized.
*
* @return Boolean
*/
2012-07-09 13:50:58 +01:00
public function isSynchronized();
/**
2011-05-10 14:32:14 +01:00
* Writes data into the form.
*
* @param mixed $data The data
*
* @return FormInterface The form instance
*/
2012-07-09 13:50:58 +01:00
public function bind($data);
2011-05-10 14:32:14 +01:00
/**
* Returns the root of the form tree.
*
* @return FormInterface The root of the tree
2011-05-10 14:32:14 +01:00
*/
2012-07-09 13:50:58 +01:00
public function getRoot();
2011-05-10 14:32:14 +01:00
/**
* Returns whether the field is the root of the form tree.
*
* @return Boolean
*/
2012-07-09 13:50:58 +01:00
public function isRoot();
2011-05-10 14:32:14 +01:00
/**
* Creates a view.
*
* @param FormView $parent The parent view
2011-05-10 14:32:14 +01:00
*
* @return FormView The view
2011-05-10 14:32:14 +01:00
*/
public function createView(FormView $parent = null);
}