Skip to content

Commit 008d8e7

Browse files
committed
Merge pull request #3 from LExpress/form
Merge form branch
2 parents 619e8fa + 239ace2 commit 008d8e7

File tree

48 files changed

+1332
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1332
-419
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CHANGELOG
22
=========
33

4+
* Added sfFormObject::saveObject() method
45
* Added skip-build option to sfDoctrineCreateModelTablesTask (patch from @estahn)
56
* better code coverage for sfWebRequest class unit tests
67
* added parameters proxy to sfWebRequest::getClientIp() method (default true)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://secure.travis-ci.org/LExpress/symfony1.png?branch=master)](http://travis-ci.org/LExpress/symfony1)
1+
[![Build Status](https://secure.travis-ci.org/LExpress/symfony1.png?branch=form)](http://travis-ci.org/LExpress/symfony1)
22

33
Symfony is a complete framework designed to optimize the development of web applications by way of several key features.
44
For starters, it separates a web application's business rules, server logic, and presentation views.

UPGRADE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,18 @@ Plugin
1111

1212
The sfPropelPlugin has been removed.
1313
Use the [sfPropelORMPlugin](https://github.com/propelorm/sfPropelORMPlugin) if you want to use the great Propel ORM.
14+
15+
Form
16+
----
17+
18+
The `trim` option of `sfValidatorBase` is now set to `true` by default.
19+
20+
The method `sfForm::embedFormForForeach` have been removed.
21+
22+
Due to the new embed form enhancements:
23+
24+
* The form is not cloned anymore when it you embed it
25+
* You cannot embed the same `sfForm` instance twice or more into an `sfForm`.
26+
* You cannot added the same `sfValidatorErrorSchema` instance twice or more into an `sfValidatorErrorSchema`.
27+
* The method `sfValidatorErrorSchema::addErrors` only accept an `sfValidatorErrorSchema` instance as argument.
28+
+ The `sfValidatorErrorSchema` constructor no longer accept an array of errors as second argument.

WHATS_NEW.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,52 @@ Service container
44
A service container have been added (extracted from the [symfony dependency injection component](http://components.symfony-project.org/dependency-injection/).
55
[More details](https://github.com/LExpress/symfony1/wiki/ServiceContainer) about the integration on symfony core.
66

7+
Form
8+
----
9+
10+
Many issues have been fixed for embedded form included:
11+
12+
* You can use `sfFormObject::updateObject()` without save, all embedded form objects are updated.
13+
* You can use file upload into your embedded forms, files will be correctly removed in embedded forms using `sfWidgetFormInputFileEditable`.
14+
* `sfFormObject::updateObject()` and `sfFormObject::save()` methods are call recursivly from embeded forms.
15+
* You can use integer in `name` argument of `sfForm::embedForm`.
16+
17+
This fixes the following tickets :
18+
19+
* http://trac.symfony-project.org/ticket/4903
20+
* http://trac.symfony-project.org/ticket/5805
21+
* http://trac.symfony-project.org/ticket/5867
22+
* http://trac.symfony-project.org/ticket/6937
23+
* http://trac.symfony-project.org/ticket/7032
24+
* http://trac.symfony-project.org/ticket/7440
25+
* http://trac.symfony-project.org/ticket/8500
26+
* http://trac.symfony-project.org/ticket/8800
27+
* http://trac.symfony-project.org/ticket/9147
28+
* http://trac.symfony-project.org/ticket/9172
29+
* http://trac.symfony-project.org/ticket/9637
30+
31+
[BC Break] The form is not cloned anymore when you passed it to `sfForm::embedForm`.
32+
33+
The method `sfForm::embedFormForForeach()` have been removed.
34+
35+
A new method `sfForm::getErrors()` have been added.
36+
This method returns an array with label as key and the validation error message as value (included embedded form errors).
37+
38+
Widget
39+
------
40+
41+
A new parameter `default` have been added to the method `sfWidget::getOption`.
42+
43+
New widget `sfWidgetFormInputRead` have been added.
44+
This allow you to display a readonly input without border, with the value of your choice AND an hidden input with real value and name for submit.
45+
46+
The method `sfWidgetFormDateRange::getStylesheets()` does not try to remove duplicate (fixes http://trac.symfony-project.org/ticket/9224).
47+
48+
Validator
49+
---------
50+
51+
A new `sfValidatorIp`have been added (extracted from symfony2).
52+
753
Action
854
------
955

@@ -48,6 +94,21 @@ Filesystem
4894
Validator
4995
---------
5096

97+
The method `sfValidatorSchema::preClean` now returns cleaned values (fixes http://trac.symfony-project.org/ticket/5952).
98+
This allow you to modified into validotors defined in your form `preValidator.
99+
100+
The method `sfValidatorErrorSchema::addError` accept all possible name different of `null` as second argement.
101+
This allow you to set integer name for named error (fixes http://trac.symfony-project.org/ticket/6112).
102+
103+
Also, the method `sfValidatorErrorSchema::addError` uses much less memory for complex form with many (recursive) embedded forms.
104+
105+
[BC Break] The method `sfValidatorErrorSchema::addErrors` only accept an `sfValidatorErrorSchema` instance as argument.
106+
107+
[BC Break] The `sfValidatorErrorSchema` constructor no longer accept an array of errors as second argument.
108+
109+
A new `sfValidatorEqual` have been added.
110+
It take one required `value` option an an optional `strict` to compare strictly or not.
111+
51112
The `sfValidatorFile` now returns size error in Kilo Byte instead of Byte.
52113

53114
A new method `sfValidator::resetType()` have been added.
@@ -95,6 +156,12 @@ This allow you to use another directory for unit tests temporary files storage.
95156
Doctrine
96157
--------
97158

159+
### Widget
160+
161+
A new `sfWidgetFormDoctrineArrayChoice` have been added.
162+
This allow you to use an array builded by a table method of a model to increase performance.
163+
See unit tests for usage examples.
164+
98165
### Form generation
99166

100167
Added column name for foreign key colums.

lib/autoload/sfCoreAutoload.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @subpackage autoload
2424
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
2525
* @version SVN: $Id: sfCoreAutoload.class.php 32415 2011-03-30 16:09:00Z Kris.Wallsmith
26-
$
26+
*
2727
*/
2828
class sfCoreAutoload
2929
{
@@ -472,19 +472,20 @@ static public function make()
472472
'sfvalidatordatetime' => 'validator/sfValidatorDateTime.class.php',
473473
'sfvalidatordecorator' => 'validator/sfValidatorDecorator.class.php',
474474
'sfvalidatoremail' => 'validator/sfValidatorEmail.class.php',
475+
'sfvalidatorequal' => 'validator/sfValidatorEqual.class.php',
475476
'sfvalidatorerror' => 'validator/sfValidatorError.class.php',
476477
'sfvalidatorerrorschema' => 'validator/sfValidatorErrorSchema.class.php',
477478
'sfvalidatorfile' => 'validator/sfValidatorFile.class.php',
478479
'sfvalidatorfromdescription' => 'validator/sfValidatorFromDescription.class.php',
479480
'sfvalidatorinteger' => 'validator/sfValidatorInteger.class.php',
481+
'sfvalidatorip' => 'validator/sfValidatorIp.class.php',
480482
'sfvalidatornumber' => 'validator/sfValidatorNumber.class.php',
481483
'sfvalidatoror' => 'validator/sfValidatorOr.class.php',
482484
'sfvalidatorpass' => 'validator/sfValidatorPass.class.php',
483485
'sfvalidatorregex' => 'validator/sfValidatorRegex.class.php',
484486
'sfvalidatorschema' => 'validator/sfValidatorSchema.class.php',
485487
'sfvalidatorschemacompare' => 'validator/sfValidatorSchemaCompare.class.php',
486488
'sfvalidatorschemafilter' => 'validator/sfValidatorSchemaFilter.class.php',
487-
'sfvalidatorschemaforeach' => 'validator/sfValidatorSchemaForEach.class.php',
488489
'sfvalidatorstring' => 'validator/sfValidatorString.class.php',
489490
'sfvalidatortime' => 'validator/sfValidatorTime.class.php',
490491
'sfvalidatorurl' => 'validator/sfValidatorUrl.class.php',
@@ -515,10 +516,10 @@ static public function make()
515516
'sfwidgetforminputfileeditable' => 'widget/sfWidgetFormInputFileEditable.class.php',
516517
'sfwidgetforminputhidden' => 'widget/sfWidgetFormInputHidden.class.php',
517518
'sfwidgetforminputpassword' => 'widget/sfWidgetFormInputPassword.class.php',
519+
'sfwidgetforminputread' => 'widget/sfWidgetFormInputRead.class.php',
518520
'sfwidgetforminputtext' => 'widget/sfWidgetFormInputText.class.php',
519521
'sfwidgetformschema' => 'widget/sfWidgetFormSchema.class.php',
520522
'sfwidgetformschemadecorator' => 'widget/sfWidgetFormSchemaDecorator.class.php',
521-
'sfwidgetformschemaforeach' => 'widget/sfWidgetFormSchemaForEach.class.php',
522523
'sfwidgetformschemaformatter' => 'widget/sfWidgetFormSchemaFormatter.class.php',
523524
'sfwidgetformschemaformatterlist' => 'widget/sfWidgetFormSchemaFormatterList.class.php',
524525
'sfwidgetformschemaformattertable' => 'widget/sfWidgetFormSchemaFormatterTable.class.php',

lib/form/addon/sfFormObject.class.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/**
1212
* Base class for forms that deal with a single object.
13-
*
13+
*
1414
* @package symfony
1515
* @subpackage form
1616
* @author Kris Wallsmith <kris.wallsmith@symfony-project.com>
@@ -24,7 +24,7 @@ abstract class sfFormObject extends BaseForm
2424

2525
/**
2626
* Returns the current model name.
27-
*
27+
*
2828
* @return string
2929
*/
3030
abstract public function getModelName();
@@ -50,7 +50,7 @@ abstract protected function doUpdateObject($values);
5050
* Processes cleaned up values.
5151
*
5252
* @param array $values An array of values
53-
*
53+
*
5454
* @return array An array of cleaned up values
5555
*/
5656
abstract public function processValues($values);
@@ -108,7 +108,7 @@ public function bindAndSave($taintedValues, $taintedFiles = null, $con = null)
108108
* @return mixed The current saved object
109109
*
110110
* @see doSave()
111-
*
111+
*
112112
* @throws sfValidatorError If the form is not valid
113113
*/
114114
public function save($con = null)
@@ -123,10 +123,9 @@ public function save($con = null)
123123
$con = $this->getConnection();
124124
}
125125

126+
$con->beginTransaction();
126127
try
127128
{
128-
$con->beginTransaction();
129-
130129
$this->doSave($con);
131130

132131
$con->commit();
@@ -150,18 +149,27 @@ public function save($con = null)
150149
* @param mixed $con An optional connection object
151150
*/
152151
protected function doSave($con = null)
152+
{
153+
$this->updateObject();
154+
$this->saveObject($con);
155+
}
156+
157+
/**
158+
* Save form object
159+
*
160+
* @param mixed $con An optional connection object
161+
*/
162+
public function saveObject($con = null)
153163
{
154164
if (null === $con)
155165
{
156166
$con = $this->getConnection();
157167
}
158168

159-
$this->updateObject();
160-
161169
$this->getObject()->save($con);
162170

163171
// embedded forms
164-
$this->saveEmbeddedForms($con);
172+
$this->saveObjectEmbeddedForms($con);
165173
}
166174

167175
/**
@@ -225,7 +233,7 @@ public function updateObjectEmbeddedForms($values, $forms = null)
225233
* @param mixed $con An optional connection object
226234
* @param array $forms An array of forms
227235
*/
228-
public function saveEmbeddedForms($con = null, $forms = null)
236+
public function saveObjectEmbeddedForms($con = null, $forms = null)
229237
{
230238
if (null === $con)
231239
{
@@ -241,12 +249,11 @@ public function saveEmbeddedForms($con = null, $forms = null)
241249
{
242250
if ($form instanceof sfFormObject)
243251
{
244-
$form->getObject()->save($con);
245-
$form->saveEmbeddedForms($con);
252+
$form->saveObject($con);
246253
}
247254
else
248255
{
249-
$this->saveEmbeddedForms($con, $form->getEmbeddedForms());
256+
$this->saveObjectEmbeddedForms($con, $form->getEmbeddedForms());
250257
}
251258
}
252259
}

0 commit comments

Comments
 (0)