Commit Graph

435 Commits

Author SHA1 Message Date
Benjamin Eberlei
6bcc04905c [Form] Introduce ArrayTypeLoader, Remove EntityManager and FormFactory interface from DefaultTypeLoader 2011-03-24 20:00:17 +01:00
Bernhard Schussek
2faa47d03b [Form] Added fallback templates to TwigThemeFactory 2011-03-24 15:11:43 +01:00
Bernhard Schussek
1211d77f49 [Form] Introduced renderer theme factories so that themes can be changed during runtime 2011-03-24 14:27:21 +01:00
Bernhard Schussek
5b41810b6d Revert "[Form] Changed naming of Themes to ThemeEngines. Theme templates are now 'themes'"
This reverts commit 1efd680b68.
2011-03-24 10:55:12 +01:00
Bernhard Schussek
5078a63c74 Revert "[Form] Fixed more naming of themes and theme engines"
This reverts commit 1aa34b7240.
2011-03-24 10:54:47 +01:00
Bernhard Schussek
1aa34b7240 [Form] Fixed more naming of themes and theme engines 2011-03-23 22:51:37 +01:00
Bernhard Schussek
1efd680b68 [Form] Changed naming of Themes to ThemeEngines. Theme templates are now 'themes' 2011-03-23 22:34:58 +01:00
Bernhard Schussek
c01419d856 Merge remote branch 'johnwards/renderer_tests' into renderer-tests-merge 2011-03-23 21:13:36 +01:00
Bernhard Schussek
08a09240f6 [Form] Fixed order of input and output timezone to a more natural one 2011-03-23 17:12:04 +01:00
Bernhard Schussek
a880f8d0d1 [Form] Fixed coding conventions 2011-03-23 16:14:53 +01:00
Bernhard Schussek
9e025440ca Merge remote branch 'johnwards/configuration' into configurable-merge 2011-03-23 16:05:16 +01:00
John Wards
1a014d130e [Form] Tests for Renderer Plugins 2011-03-22 22:19:51 +00:00
John Wards
2e750f7287 [Form] Coding conventions 2011-03-22 21:02:02 +00:00
John Wards
ef8113c50f [Form] Base tests for renderers 2011-03-22 20:51:19 +00:00
Bernhard Schussek
ea0e5bb2d6 [Form] Renamed FieldTypeInterface to FormTypeInterface 2011-03-22 12:36:41 +01:00
Bernhard Schussek
270a98e413 [Form] Added support for types that are not registered in the DIC. These are identified by their FQ class name. 2011-03-22 12:33:15 +01:00
John Wards
5a5fdd0529 Merge remote branch 'bernhard/experimental' into configuration 2011-03-22 07:43:47 +00:00
Bernhard Schussek
33692eae4a [Form] Renamed Form::isTransformationSuccessful() to isSynchronized(). This method now indicates whether the data in the different representations is synchronized. Moved 'invalid' error to DefaultValidator 2011-03-22 02:03:22 +01:00
Bernhard Schussek
16d65f6f16 [Form] Moved previously skipped tests from FormTypeTest to FormTest and fixed them 2011-03-22 01:40:02 +01:00
Bernhard Schussek
577e106361 [Form] Implemented custom mapping of data errors to form fields 2011-03-22 01:15:48 +01:00
John Wards
b4406f254d [Form] Removing Configurable from DataTransformers 2011-03-21 23:01:10 +00:00
John Wards
27267e8007 [Form] Refactoring tests for new DataTransfomer 2011-03-21 21:46:20 +00:00
Bernhard Schussek
87665bc380 [Form] Decoupled FormBuilder from CSRF protection 2011-03-21 22:41:19 +01:00
Bernhard Schussek
c1abf08d9c [Form] Implemented error bubbling 2011-03-21 22:13:02 +01:00
Bernhard Schussek
01a47457d0 [Form] Improved naming of various interfaces. Renamed DefaultRenderer to ThemeRenderer 2011-03-21 20:57:38 +01:00
Bernhard Schussek
321d40b21a [Form] Decoupled FormBuilder from ThemeInterface 2011-03-21 20:46:43 +01:00
Bernhard Schussek
4989e965cd [Form] Moved form type tests into according namespace 2011-03-20 15:45:09 +01:00
Bernhard Schussek
119866e06d [Form] Renamed FormBuilder::getInstance() to getForm() 2011-03-20 15:17:25 +01:00
Bernhard Schussek
2dbb41714a [Form] Merged Field and Form. Merged FieldBuilder and FormBuilder. After the refactoring, the distinction between the two concepts is small enough to merge them 2011-03-20 13:35:19 +01:00
Bernhard Schussek
fc7281bcab [Form] Extracted validation logic of form. Fields can now contain multiple validators 2011-03-20 12:00:19 +01:00
Bernhard Schussek
cb599f417e [Form] Renamed field option 'disabled' to 'read_only'. How to render read-only fields is now the responsibility of the renderer 2011-03-20 10:35:16 +01:00
Bernhard Schussek
295d01745b [Form] Renamed StripTagsFilter to StripTagsListener until we have better conventions 2011-03-20 10:26:38 +01:00
Bernhard Schussek
2c6c89d898 Merge remote branch 'beberlei/forms' into beberlei-merge 2011-03-20 10:15:59 +01:00
Benjamin Eberlei
b43318ee3e [Form] Add tests for untested classes. 2011-03-19 22:03:49 +01:00
Benjamin Eberlei
d62213662e Merge branch 'experimental' of git://github.com/bschussek/symfony into forms 2011-03-19 20:36:56 +01:00
Benjamin Eberlei
864a3ec45f [Form] Add StripTagsFilter EventListener 2011-03-19 20:36:49 +01:00
Bernhard Schussek
6793bcd698 [Form] Removed magic from method signature of add() 2011-03-19 19:20:55 +01:00
Bernhard Schussek
c4b7a77ece Merge remote branch 'beberlei/forms' into beberlei-merge
Conflicts:
	src/Symfony/Component/Form/Type/Loader/DefaultTypeLoader.php
2011-03-19 19:01:57 +01:00
Benjamin Eberlei
39c2d3f166 [Form] Add PhpTheme that relies on no Template Engine, generalize tests to use for PhpTheme and PhpEngineTheme. Fixed some bugs 2011-03-19 17:47:18 +01:00
Bernhard Schussek
43a24fa931 [Form] Renamed events to match terminology in Field 2011-03-19 16:59:23 +01:00
Bernhard Schussek
7f9284105d [Form] Moved namespace FieldGuesser to Type\Guesser 2011-03-19 16:46:03 +01:00
Bernhard Schussek
6bc79a1a12 [Form] Renamed different kinds of data transformers within a field for better clarity 2011-03-18 16:59:34 +01:00
Bernhard Schussek
2a1e394352 [Form] Renamed field configs to types. Everywhere else, we are referring to the name of the type as 'type' now (was 'identifier') 2011-03-18 16:20:00 +01:00
Bernhard Schussek
0b929ee342 [Form] Renamed ValueTransformers to DataTransformers to fit with DataMapper and DataValidator 2011-03-18 16:01:06 +01:00
Bernhard Schussek
97d0183d84 [Form] Moved properties propertyPath, modifyByReference, validationGroups and virtual to generic attributes because they are specific to the used data validator/mapper implementations 2011-03-18 15:26:02 +01:00
Bernhard Schussek
700c96e7fa [Form] Moved FieldFactoryTest to FormFactoryTest and fixed it 2011-03-18 14:37:54 +01:00
Bernhard Schussek
9caaf0f3a3 [Form] Introduced FieldBuilder for field/form creation and made Field/Form mostly immutable 2011-03-18 12:50:26 +01:00
Bernhard Schussek
3f70f89339 Merge remote branch 'symfony/master' into experimental
Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
	src/Symfony/Component/HttpFoundation/File/UploadedFile.php
2011-03-18 10:39:40 +01:00
Kris Wallsmith
0a229947a6 [Form] updated tests for changes in HttpFoundation 2011-03-17 16:09:12 -07:00
Bernhard Schussek
a51321c264 [Form] Moved validation logic to ValidationListener 2011-03-17 21:47:12 +01:00
Bernhard Schussek
0799662361 [Form] Extracted data mapping logic from Form into ObjectMapperListener 2011-03-17 21:23:59 +01:00
Bernhard Schussek
7a63b840f3 [Form] Renamed submit() to bind() 2011-03-17 14:55:26 +01:00
Bernhard Schussek
5bfd02bcd0 [Form] Renamed bind() to bindRequest(). It is now semantically the same as in symfony1 again 2011-03-17 14:51:22 +01:00
Bernhard Schussek
ffa5bd264a [Form] Moved logic of Field::isMultipart() to rendering layer 2011-03-17 14:40:34 +01:00
Bernhard Schussek
50ce0d53a0 [Form] Removed FieldInterface::getDisplayedData(). Use getTransformedData() instead 2011-03-17 14:28:59 +01:00
Bernhard Schussek
f0d841ef8c [Form] Fixed DateTimeToArrayTransformer when transforming empty values and the option 'fields' is set 2011-03-17 14:27:10 +01:00
Bernhard Schussek
cb283d3783 [Form] Renamed 'key' to 'name'. Removed setKey() totally. 2011-03-17 11:03:10 +01:00
Bernhard Schussek
e85aab2dc1 [Form] Changed form to use the new EventDispatcher implementation 2011-03-16 18:20:13 +01:00
Bernhard Schussek
fb8efaba67 [Form] Fixed a couple of failing tests 2011-03-16 16:13:06 +01:00
Bernhard Schussek
0bf566310c Merge branch 'event-manager' into experimental
Conflicts:
	src/Symfony/Component/Form/BirthdayField.php
	src/Symfony/Component/Form/CheckboxField.php
	src/Symfony/Component/Form/ChoiceField.php
	src/Symfony/Component/Form/ChoiceList/TimeZoneChoiceList.php
	src/Symfony/Component/Form/CollectionField.php
	src/Symfony/Component/Form/DateField.php
	src/Symfony/Component/Form/DateTimeField.php
	src/Symfony/Component/Form/EntityChoiceField.php
	src/Symfony/Component/Form/Events.php
	src/Symfony/Component/Form/FieldFactory/FieldFactory.php
	src/Symfony/Component/Form/FieldFactory/FieldFactoryInterface.php
	src/Symfony/Component/Form/FileField.php
	src/Symfony/Component/Form/Filters.php
	src/Symfony/Component/Form/FormContext.php
	src/Symfony/Component/Form/FormContextInterface.php
	src/Symfony/Component/Form/FormFactoryInterface.php
	src/Symfony/Component/Form/HybridField.php
	src/Symfony/Component/Form/IntegerField.php
	src/Symfony/Component/Form/LanguageField.php
	src/Symfony/Component/Form/LocaleField.php
	src/Symfony/Component/Form/MoneyField.php
	src/Symfony/Component/Form/NumberField.php
	src/Symfony/Component/Form/PasswordField.php
	src/Symfony/Component/Form/PercentField.php
	src/Symfony/Component/Form/RepeatedField.php
	src/Symfony/Component/Form/TextField.php
	src/Symfony/Component/Form/TimeField.php
	src/Symfony/Component/Form/ToggleField.php
	src/Symfony/Component/Form/UrlField.php
	src/Symfony/Component/HttpFoundation/File/UploadedFile.php
	tests/Symfony/Tests/Component/Form/FileFieldTest.php
	tests/Symfony/Tests/Component/Form/FormContextTest.php
	tests/Symfony/Tests/Component/Form/HiddenFieldTest.php
2011-03-13 21:04:24 +01:00
Jordi Boggiano
991b1ed225 [HttpFoundation] UploadedFile::getOriginalName is now overriding getName 2011-03-09 17:26:08 +01:00
Jordi Boggiano
88cfc4c011 [Form] Add exception for missing enctype attribute 2011-03-09 17:23:21 +01:00
Fabien Potencier
8c423edfef replaced symfony-project.org by symfony.com 2011-03-06 12:40:06 +01:00
Bernhard Schussek
5705f74bd0 [Form] Refactored FieldFactory and moved new implementation into the DIC. FormTest fails now. 2011-03-02 14:58:19 +01:00
Bernhard Schussek
8a6246bd06 [Form] Refactored contents of FormFactory into individual FieldConfig classes 2011-03-02 12:20:30 +01:00
Bernhard Schussek
9eff64dd54 [Form] Added EventListener implementation and moved CollectionField to factory 2011-03-01 15:18:55 +01:00
Bernhard Schussek
528ef55da6 [Form] Implemented generic data filter hooks
You can now modify set or bound data by adding a filter for either of the following events:

* Filters::filterBoundDataFromClient
* Filters::filterBoundData
* Filters::filterSetData
2011-03-01 14:19:28 +01:00
Bernhard Schussek
c1edf116f2 [Form] Removed notion of "hidden" fields
Instead, hidden fields now override the "row" template to not include a label or errors.

The "rest" (former "hidden") helper has been adapted to output any fields that were not
rendered manually. It should usually be called at the end of a form.
2011-02-28 17:01:11 +01:00
Bernhard Schussek
02d2121dcd [Form] Improved rendering
Fields are not available in the templates anymore. Instead, all required information can be
accessed through view variables.

Example usage of helpers and variables in a form theme:

// use the label helper
{{ this.label('my label') }}

// use the label variable
{{ this.vars.label }}
{{ label }}

Example usage of helpers and variables in a normal template:

// use the label helper
{{ field.label('my label') }}

// use the label variable
{{ field.vars.label }}
2011-02-28 16:50:23 +01:00
Bernhard Schussek
e334c4734e [Form] Registered FormFactory in the DIC 2011-02-24 21:27:44 +01:00
Bernhard Schussek
f2c1976da6 [Form] Refactored FileField to FormFactory and fixed file upload mechanism 2011-02-24 20:47:48 +01:00
Bernhard Schussek
848ec01f02 [Form] Refactored RepeatedField to FormFactory 2011-02-24 16:54:34 +01:00
Bernhard Schussek
0f8a413221 [Form] Fixed EntityChoiceFieldTest 2011-02-24 16:26:57 +01:00
Bernhard Schussek
acc5c76f77 [Form] Fixed failing DateFieldTest and TimeFieldTest 2011-02-24 16:19:59 +01:00
Bernhard Schussek
e3e8c29875 Merge branch 'bugfix' into experimental
Conflicts:
	src/Symfony/Component/Form/EntityChoiceField.php
	src/Symfony/Component/Form/Field.php
	src/Symfony/Component/Form/HybridField.php
	tests/Symfony/Tests/Component/Form/FieldTest.php
	tests/Symfony/Tests/Component/Form/FormTest.php
2011-02-24 13:17:53 +01:00
Bernhard Schussek
87e6cbf8f0 [Form] Fixed: PropertyPath always requires arrays or objects. Forms now always store arrays or objects as transformed data, even when they were bound empty 2011-02-24 12:22:00 +01:00
Bernhard Schussek
0e75891f25 [Form] Fixed DateTimeToLocalizedStringTransformerTest 2011-02-24 10:05:35 +01:00
Bernhard Schussek
8e2d0bae90 [Form] Ported DateTimeField to FormFactory 2011-02-23 23:34:25 +01:00
Bernhard Schussek
b5671c1be0 [Form] Implemented ArrayToPartsTransformer and ValueToDuplicatesTransformer 2011-02-23 22:30:15 +01:00
Bernhard Schussek
ac5440f8d4 [Form] DateTimeToArrayTransformer does not accept partially filled arrays anymore. Replaces DateField::isPartiallyFilled() and TimeField::isPartiallyFilled() 2011-02-23 21:17:20 +01:00
Bernhard Schussek
a40e2dd77b [Form] Deleted obsolete Field classes, ported some more to FormFactory and fixed lots of failing tests 2011-02-23 14:11:18 +01:00
Bernhard Schussek
7492873186 [Form] Fixed a couple of unit tests, refactored PasswordField to FormFactory 2011-02-23 14:11:18 +01:00
Bernhard Schussek
fee0885256 [Form] Moved options from Field and Form to FormFactory. Tests fail now 2011-02-23 14:11:18 +01:00
Bernhard Schussek
7a48c0a5c5 [Form] Refactored logic from ChoiceField into ChoicePlugin and SelectMultipleNamePlugin 2011-02-23 14:11:18 +01:00
Bernhard Schussek
f7dc71ef59 [Form] Refactored id and name generation to renderer plugins 2011-02-23 14:11:17 +01:00
Bernhard Schussek
813ec54fa1 [Form] Refactored parts of the choice fields into ChoiceList instances 2011-02-23 14:11:17 +01:00
Bernhard Schussek
9569262635 [Form] Fixed date handling classes to use server timezone by default 2011-02-16 23:05:22 +01:00
Bernhard Schussek
0a260b96fb [Form] Fixed error handling in DateTimeToArrayTransformer 2011-02-16 23:05:22 +01:00
Bernhard Schussek
df011ed1ef [Form] Fixed isXXXWithinRange() methods in TimeField and DateField to ignore empty dropdowns 2011-02-16 23:05:22 +01:00
Bernhard Schussek
14c3518c6e [Form] Fixed: If a DateField or TimeField is displayed with select boxes, either all or no select box must have a value selected 2011-02-16 23:05:22 +01:00
Bernhard Schussek
40acc6ac79 [Form] Fixed ChoiceField::isChoiceSelected() to differentiate between zero and empty 2011-02-16 23:05:21 +01:00
Bernhard Schussek
1593d6f75d [Form] Added method FieldInterface::isEmpty() 2011-02-16 23:05:21 +01:00
Bernhard Schussek
7dbc09ed8b [Form] Fixed reference handling in forms. Sometimes data wasn't written into the domain object, resulting in failed validation. 2011-02-15 21:39:32 +01:00
Bernhard Schussek
f51dafca3f [Form] Fixed: "data_constructor" option is used even if "data_class" option is not set 2011-02-08 04:14:56 +01:00
Bernhard Schussek
5b95805340 [Form] Added option "data_constructor" to Form. When a Form is initialized with NULL, an object is automatically created using this constructor. If no constructor is given but the option "data_class" is set, an object of that class is created with the default constructor instead. 2011-02-08 04:14:56 +01:00
Bernhard Schussek
09a50c3c55 [Form] Fixed: "by_reference" option is ignored if reading from/writing to an array 2011-02-08 04:14:55 +01:00
Bernhard Schussek
74d0ac82f7 [Form] Cleaned up ValueTransformerInterface
This commit removes CollectionToStringTransformer. Transformers should never change the state of the outside world, otherwise hard-to-track bugs might creap in.

This functionality needs to be implemented as a custom FieldType (see EntityChoiceField).
2011-02-06 19:46:29 +01:00
Bernhard Schussek
bd3e6c6b49 [Form] Fixed: Form::bind() throws an exception if form is anonymous 2011-02-06 19:46:28 +01:00
Bernhard Schussek
6ff4120784 [Form] Added Form option "by_reference" so that objects received from parent forms are modified by reference when this option is true (the default)
The implication is that set<Reference>() in the object of the parent form will not be called (and thus not has to be implemented/public).

If you want to suppress this behaviour, manually set "by_reference" to false.
2011-02-06 19:46:28 +01:00
Bernhard Schussek
2276b98fc1 [Form] Fixed: ChoiceFields never validated 2011-02-04 11:30:49 +01:00
Bernhard Schussek
a725415440 [Form] Fixed RepeatedField not to trigger NotNull/NotBlank errors if any of the fields was filled in 2011-02-03 13:28:29 +01:00
Bernhard Schussek
39c148197f [Form] Fixed form validation
Separated validation of data and form had serious drawbacks. When a form had nested form whose data was not connected to the data of the root form, this data would not be validated.

The new implementation validates the whole object graph at once. Class Form has a new method validateData(), that manually passes the data to the GraphWalker of the Validator and overrides the Default group with the groups set in the form.
2011-02-03 13:21:44 +01:00
Bernhard Schussek
50955a3919 [Validator] Fixed PropertyPath to read array indices with special characters 2011-02-03 11:28:51 +01:00
Bernhard Schussek
7c9c7af863 [Form] Fixed arrays not to be passed to the validator 2011-02-02 17:32:24 +01:00
Bernhard Schussek
5e3fab214e [Form] The form is now validated seperatedly from its data. The form is validated in group "Default", the data in the group set in option "validation_groups" 2011-02-02 15:25:05 +01:00
Bernhard Schussek
c923af2879 [Form] Adapted constructor of CollectionField to match the constructors of the other fields. The field prototype is now optional. 2011-02-02 14:46:33 +01:00
Bernhard Schussek
4f0283a508 [Form] Removed Form::isBound(). Form::bind() is only a shortcut method now, use Form::isSubmitted() if you want to find out whether a form was submitted. 2011-02-02 14:46:33 +01:00
Bernhard Schussek
628a4d1fd8 [Form] Refactored validation logic into validate() method. Removed bindGlobals() to reduce API clutter 2011-02-02 14:46:33 +01:00
Jeremy Mikola
4e0db56810 [Form] Fix getValidator() to reference the "validator" option instead of property 2011-02-02 11:34:18 +01:00
Bernhard Schussek
a28151a8af [Form] Removed FormFactory and improved the form instantiation process
With the form factory there was no reasonable way to implement instantiation of custom form classes. So the implementation was changed to let the classes instantiate themselves. A FormContext instance with default settings has to be passed to the creation method. This context is by default configured in the DI container.

	$context = $this->get('form.context');
	// or
	$context = FormContext::buildDefault();
	$form = MyFormClass::create($context, 'author');

If you want to circumvent this process, you can also create a form manually. Remember that the services stored in the default context won't be available then unless you pass them explicitely.

	$form = new MyFormClass('author');
2011-02-01 15:27:12 +01:00
Bernhard Schussek
fb1f99137d [Form] Changed semantics of a "bound" form
A form now always has to be bound, independent of whether the request is a POST request or not. The bind() method detects itself whether the request was a post request or not and reads its data accordingly. The "old" bind()/isBound() methods were renamed to submit()/isSubmitted().

	$form = new Form('author');
	$form->bind($request, $author);

	if ($form->isValid()) {
		// isValid() implies isSubmitted(), non-submitted forms can
		// never be valid
		// do something with author now
	}

Alternatively, you can only bind global variables, if you don't have a request object.

	$form->bindGlobals($author);

Note that the $author object is in both cases optional. You can also pass no object at all and read the data using $form->getData(), but then no validation will occur. You can also prefill the form with an object during instantiation.

	$form = new Form('author', array('data' => $author));
	$form->bind($request);

	// etc.
2011-02-01 15:27:12 +01:00
Bernhard Schussek
e5ed98c324 [Form] Added option 'data' to Field for populating a field with a fixed value 2011-02-01 15:27:12 +01:00
Bernhard Schussek
fdbc064f06 [Form] Removed automatic distribution of the locale in the Form component. This leads to more problems than it solves. 2011-02-01 15:27:12 +01:00
Bernhard Schussek
c468db5c5b [Form] Merged classes FieldGroup and Form for simplicity 2011-02-01 15:27:12 +01:00
Bernhard Schussek
4fcb98547c [Form] Simplified Form::bind(), added convenience methods Form::bindRequest() and Form::bindGlobals() 2011-02-01 15:27:12 +01:00
Bernhard Schussek
57cbd57265 [Form] Fields may now be anonymous, but anonymous fields must not be added to groups. They can only be used as prototypes 2011-02-01 15:27:12 +01:00
Bernhard Schussek
d152b5e265 [Form] Moved Doctrine2 specific files 2011-02-01 15:27:12 +01:00
Bernhard Schussek
347c069e8d [DoctrineBundle][Form] Implemented EntityChoiceField 2011-02-01 15:27:12 +01:00
Bernhard Schussek
ebd2ca6cfe [Form] Moved option 'empty_value' to ChoiceField. An empty value is displayed if the field is not required. 2011-01-28 09:22:06 +01:00
Bernhard Schussek
ce61baf717 [Form] ChoiceField now accepts closures in the 'choices' option 2011-01-28 09:20:41 +01:00
Fabien Pennequin
c392f2518d [Form][Validator] Fixed indentation 2011-01-26 10:36:10 +01:00
Bernhard Schussek
d017970867 [Form] Implemented FormFactory::buildDefault() to ease the use of the new CSRF implementation without the DIC 2011-01-25 11:31:04 +01:00
Bernhard Schussek
7848a7ca63 [Form] Refactored CSRF implementation to be reusable and to work correctly with the session service 2011-01-25 11:31:04 +01:00
Ryan Weaver
d341e8bccb [Form] Adding PHPDoc to many Field objects and making other small changes:
* Added empty_value option on CountryField, LanguageField, LocaleField, TimezoneField
 * Added missing date_pattern to DateTimeField
 * Made the currency option on MoneyField required.
2011-01-25 11:10:25 +01:00
Bernhard Schussek
bdd2c91abd [Form] Fixed failing test 2011-01-19 17:51:07 +01:00
Jordi Boggiano
d928632583 [Form] Made RepeatedField sub-field names configurable 2011-01-19 16:36:57 +01:00
Bernhard Schussek
8f8f53d631 [Form][FrameworkBundle] Implemented FormFactory and added it to the DI container 2011-01-19 16:25:50 +01:00
Dominique Bongiraud
64fb94c725 normalized license messages in PHP files 2011-01-18 08:07:46 +01:00
Bernhard Schussek
4b78c4376f [Form] Added FieldFactory mechanism to automatically create fields by introspecting metadata of a class 2011-01-05 15:02:56 +01:00
Bernhard Schussek
acdd5c06de [Form] Changed value transformers to throw UnexpectedTypeException instances 2011-01-03 22:07:08 +01:00
Bernhard Schussek
48af2fc86e [Form][FrameworkBundle][HttpFoundation] The session is now automatically started when a form is CSRF protected 2011-01-03 22:07:04 +01:00
Bernhard Schussek
e9a7531a26 [Form] added the constrained method Field::isTransformationSuccessful() 2011-01-03 22:06:59 +01:00
Bernhard Schussek
8513082007 [Form][HttpFoundation] Improved File and UploadedFile class 2011-01-03 22:06:56 +01:00
Bernhard Schussek
ba422e8472 [Form] Added support for virtual field groups 2011-01-03 22:06:46 +01:00
Bernhard Schussek
b9c2e98315 [Form][Locale] Implemented LocaleField and added script for updating ICU data 2011-01-02 10:41:05 +01:00
Bernhard Schussek
cd64046811 [Form] Changed semantics of "always_empty" option in PasswordField
If the option is true, the password is never written into the input field's value. If it is false, it is only written into the input field's value after submitting a form with errors.

The default value for "always_empty" is true.
2010-12-18 08:06:15 +01:00
Bernhard Schussek
93d3716a84 [Form] Implemented LanguageField 2010-12-16 10:18:32 +01:00
Bernhard Schussek
9db7db4439 [Form] Implemented CountryField 2010-12-16 10:18:31 +01:00
Bernhard Schussek
78b69876d4 [Form] Locale can now only be set statically before creating a form/field, otherwise we have too many problems updating a field's state when the locale is changed 2010-12-16 10:18:31 +01:00
Bernhard Schussek
7c557d0d6e [Form] Made and parameter in the constructor optional 2010-12-16 10:18:31 +01:00
Bernhard Schussek
b8ef7e7332 [Form] Improved semantics of property paths and removed FieldGroup::merge() for now
The semantics of property paths are now:

   (1) if a property path is set, it is _always_ respected (relative to the object
       of the parent field)
   (2) if no property path is set, the object of the parent field is _always_ ignored

Fact (2) allows us to set data into fields that is updated independently of the parent
field (like CSRF tokens, subforms with different objects etc.)

What is missing now is support for subfields that pass the object of the parent field
through to their own subfields. This functionality would be needed for GoogleMapFields,
DateRangeFields etc., which are compositions of individual fields that update the
parent object of the FieldGroup.

There are several alternatives for the latter functionality that should be discussed
in a RFC.
2010-12-16 10:18:31 +01:00
Bernhard Schussek
242be933d5 [Form] Added proper error handling to FileField 2010-12-16 10:18:31 +01:00
Johannes M. Schmitt
b3081c79e9 CS fixes 2010-12-13 11:10:55 +01:00
GordonsLondon
f73b6b4e1c [PropertyPath] Fixed usage of __get() and __set() when accessing properties that exist in the object but are not public 2010-12-10 14:28:04 +01:00
Bernhard Schussek
e80aa9a5ab [Form] Fixed: The data in a CollectionField is resized down if fields are removed 2010-12-10 14:27:57 +01:00
Bernhard Schussek
131b3fe373 [Form] Refactored Field and FieldGroup to facilitate modifications in subclasses 2010-12-10 14:27:54 +01:00
Kris Wallsmith
3e02eafc70 Fixed visibility of PHPUnit setUp and tearDown methods. 2010-12-06 15:52:23 +01:00
Fabien Potencier
1e983a6115 moved static Form configuration to a new class (avoid loading 7 classes just to enable CSRF -- even when no form is present in the page) 2010-11-26 17:44:17 +01:00
Fabien Potencier
30ccd0b794 [Form] fixed unit test paths 2010-11-23 06:59:26 +01:00
Bernhard Schussek
e0aa3f30a8 [Form] Improved FileField to store files in a temporary location in case validation fails 2010-11-23 06:51:30 +01:00
Bernhard Schussek
f9e830caa2 [Form] Added hook method preprocessData() to FieldGroup 2010-11-23 06:51:13 +01:00
Bernhard Schussek
e0d6aad5f4 [Form][FrameworkBundle][TwigBundle] Introduced class FieldError to wrap form errors 2010-11-19 07:11:29 +01:00
Bernhard Schussek
681ce7f46a [Form] Fixed: FieldGroup::hasErrors() does not return true if only children have errors 2010-11-19 07:11:17 +01:00
Bernhard Schussek
3127312139 [Form] Added option 'value_transformer' and 'normalization_transformer' to Field class 2010-11-16 07:28:33 +01:00
Jordi Boggiano
0bdb271608 [Form] Added parent calls to all configure() methods of Fields and Transformers
The calls that were on top of the function have also been moved to the bottom for safety (see previous commit)
2010-11-16 07:28:12 +01:00
GordonsLondon
23ac47e011 [Form] Added support for __get and __set in PropertyPath 2010-11-16 07:28:07 +01:00
Jordi Boggiano
a198bbcf43 [Form] throw an exception if session_id() is empty when a csrf token is generated 2010-11-12 17:53:29 +01:00
Bernhard Schussek
f5b451f5b9 [Form] Fixed MoneyToLocalizedStringTransformer and added tests 2010-11-12 17:52:56 +01:00
Bernhard Schussek
96a0bff915 [Form] Made InputField instantiable so that simple input fields can be created on the fly 2010-10-22 08:30:14 +02:00
Bernhard Schussek
72dcee594a [Form] Added validiation of hours, minutes and seconds to TimeField 2010-10-22 08:30:14 +02:00
Bernhard Schussek
6c7fab212b [Form] Added validation of years, months and days to DateField 2010-10-22 08:30:13 +02:00
Bernhard Schussek
e4c21708ca [Form] Separated value transformers from normalization transformers.
Fields can now easier support different data types in their underlying object.
These datatypes can be normalized to a single datatype using a normalization
transformer. The normalized value can then be transformed to the user's
representation with the value transformer (better name required?).
2010-10-22 08:30:13 +02:00
Bernhard Schussek
733290c112 [Form] Implemented UrlField 2010-10-22 08:30:13 +02:00
Bernhard Schussek
eaef939141 [Form] Changed value transformers to be responsible for processing empty values to be able to chain them properly. This change fixes the bug that DateField did not return NULL when submitted without values 2010-10-22 08:30:13 +02:00
Jeremy Mikola
df9ef79953 [Form] readPropertyPath should return null instead of empty array
When reading the last bit of a property path mapped to a missing array index, the method would initialize the value to an empty array.  This makes sense for cases where readPropertyPath would again be called recursively, but not when the value would be immediately returned (null would be preferable in that case).

For example, we have an object with a property called "options" that's an array of arbitrary key/value pairs.  That "options" property (and getOptions()) maps directly to a FieldGroup within the Form for this object.  That FieldGroup contains multiple TextFields for a few expected keys in the array.  As-is, if those keys were not defined, the default data set for those TextFields could end up being "Array" (string representation of an empty array).  If readPropertyPath instead returns null for this case, the default data would be transformed into an empty string.
2010-10-13 08:17:05 +02:00
Bernhard Schussek
b902cb31d7 [Form] PropertyPath camelizes property names when setting values 2010-10-11 12:52:22 +02:00
Bernhard Schussek
a66d883afd [Form] Removed CSRF setters because they have no effect once CSRF protection is enabled. Re-enable CSRF protection with the desired values instead 2010-10-11 12:52:17 +02:00
Bernhard Schussek
e1be4e9689 [Form] Refactored logic to read and set values from Field to PropertyPath 2010-10-11 12:52:10 +02:00
ornicar
06a6b15e22 [Form] Fix FieldGroup::getHiddenFields, add tests for FieldGroup::getHiddenFields and FieldGroup::getVisibleFields 2010-10-09 14:20:06 +02:00
Benjamin Eberlei
f033fc5578 Refactor ValueTransformers to recieve the original value when reverseTransform() is called. This is required for expensive value transformations for example Doctrine Collections or Proxies to allow access to a value that does not trigger expensive operations (such as database calls) anymore. 2010-10-06 14:16:47 +02:00
Fabien Potencier
2525998f6e replaced form field rendering with plain templates
Documentation available here:

http://docs.symfony-reloaded.org/master/guides/form/
2010-10-05 08:34:33 +02:00
Brandon Turner
bda264bb81 [Form] Removed invalid unit test
The bind() method only accepts arrays - passing objects causes an exception
2010-09-27 17:54:43 +02:00
Brandon Turner
953a81372a [Form] fixed typo in unit test 2010-09-25 07:57:58 +02:00
Brandon Turner
c3b89eeedd [Form] fixed failing unit test due 2010-09-25 07:57:57 +02:00
Brandon Turner
a305eb063d [Form] added support for rounding-mode option on NumberFields 2010-09-25 07:57:57 +02:00
Brandon Turner
2052501634 [Form] fixed missing locale setting in unit tests 2010-09-25 07:57:57 +02:00
Jeremy Mikola
57c0ce0ec1 [Form] Remove support for ArrayObject as ChoiceField's choices option
Internally, ChoiceField expects both choices and preferred_choices to be a simple array, so I replaced incomplete bits of code that attempted to not modify a possible ArrayObject and instead added type checks in the configure() method (with unit tests for expected exceptions).
2010-09-10 19:30:59 +02:00
Jeremy Mikola
fb24b291c8 [Form] FieldGroup::addError() can now map errors to fields within nested FieldGroups
Property paths such as fields[group].fields[innerGroup].data were not being resolved correctly, since the second iteration of addError() (based on "group") would attempt to call get('fields') instead of get('innerGroup').  Solution is to remember to bump the propertyPath forward if we're at the fields property
2010-09-09 16:29:38 -04:00
Jeremy Mikola
9be7cbb115 [Form] CollectionField::setData() should remove old fields missing from new data 2010-09-09 16:27:18 -04:00
Jeremy Mikola
9f5469f62d [Form] Test case for binding a collection of field groups with an ArrayObject of objects. 2010-09-09 16:11:31 -04:00
Jeremy Mikola
b3648b219b [Form] Fixed testBindSingleExpanded (was testing multiple, non-expanded) 2010-09-09 16:08:45 -04:00
Jeremy Mikola
e52cf7afe0 [Form] ChoiceField tests for numeric choices 2010-09-09 16:06:55 -04:00
Jeremy Mikola
2b776bf2e8 [Form] ChoiceField test for using ArrayObject as choices option 2010-09-09 16:03:44 -04:00
Fabien Potencier
a141c98917 [HttpFoundation] moved File Component into the HttpFoundation one 2010-09-09 17:01:48 +02:00
Fabien Potencier
bf82cf42dd renamed Symfony\Components to Symfony\Component 2010-08-20 23:09:55 +02:00