Permalink
Browse files

add empty_decorator option for embedRelation

  • Loading branch information...
1 parent c6cdaf4 commit b1881ab6495b32f26fd0a2d237fa21241b2cfd40 @themouette themouette committed Dec 15, 2011
Showing with 4 additions and 1 deletion.
  1. +1 −0 doc/form.md
  2. +3 −1 lib/form/sfFormPropel.class.php
View
@@ -263,6 +263,7 @@ If `add_empty` is set to `true`, the following additional options are available:
* `empty_label`: The label of the empty form. Defaults to 'new' + the relation name.
* `add_link`: The text of the JavaScript link that displays the empty form. Defaults to `Add new`
* `max_additions`: The max number of additions accepted on the client side. Defaults to 0 (no limit)
+* `empty_decorator`: The empty field decorator. `default null`.
If `add_delete` is set to `true`, the following additional options are available:
@@ -640,6 +640,7 @@ public function getRelationForm($relationName, $options = array())
* - 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
*
* @param string $relationName The name of a relation of the current Model, e.g. 'Book'
* @param sfFormPropelCollection $relationForm The form to augment
@@ -653,6 +654,7 @@ protected function addEmptyRelationForm($relationName, $relationForm, $emptyName
'add_empty' => true,
'max_additions' => 0,
'add_link' => 'Add new',
+ 'empty_decorator' => null
), $options);
$count = $relationForm->getCollection()->count();
@@ -667,7 +669,7 @@ protected function addEmptyRelationForm($relationName, $relationForm, $emptyName
$options['max_additions'] = $options['max_additions'] - $count;
}
$emptyForm = $this->getEmptyRelatedForm($relationName, $options);
- $relationForm->embedOptionalForm($emptyName, $emptyForm, null, $options);
+ $relationForm->embedOptionalForm($emptyName, $emptyForm, $options['empty_decorator'], $options);
$this->optionalForms[$prefix . $emptyName] = $emptyForm;
}

0 comments on commit b1881ab

Please sign in to comment.