Author: ornicar2
Date: 2010-02-03 17:56:41 +0100 (Wed, 03 Feb 2010)
New Revision: 27503
Modified:
plugins/diemPlugin/trunk/dmCorePlugin/lib/form/dmFormField.php
plugins/diemPlugin/trunk/dmCorePlugin/test/unit/dmFormTest.php
Log:
[Diem]
- added ->help() to widget rendering fluent interface with possibility to
override the help message
- added widget rendering fluent interface unit tests
Modified: plugins/diemPlugin/trunk/dmCorePlugin/lib/form/dmFormField.php
===================================================================
--- plugins/diemPlugin/trunk/dmCorePlugin/lib/form/dmFormField.php
2010-02-03 16:50:18 UTC (rev 27502)
+++ plugins/diemPlugin/trunk/dmCorePlugin/lib/form/dmFormField.php
2010-02-03 16:56:41 UTC (rev 27503)
@@ -65,6 +65,20 @@
return $this;
}
+
+ public function help($help = null)
+ {
+ if (null === $this->parent)
+ {
+ throw new LogicException(sprintf('Unable to render the help for "%s".',
$this->name));
+ }
+
+ $help = null === $help ? $this->parent->getWidget()->getHelp($this->name)
: $help;
+
+ $this->htmlBuffer .=
$this->parent->getWidget()->getFormFormatter()->formatHelp($help);
+
+ return $this;
+ }
public function setIsRequired($val)
{
Modified: plugins/diemPlugin/trunk/dmCorePlugin/test/unit/dmFormTest.php
===================================================================
--- plugins/diemPlugin/trunk/dmCorePlugin/test/unit/dmFormTest.php
2010-02-03 16:50:18 UTC (rev 27502)
+++ plugins/diemPlugin/trunk/dmCorePlugin/test/unit/dmFormTest.php
2010-02-03 16:56:41 UTC (rev 27503)
@@ -4,7 +4,7 @@
$helper = new dmUnitTestHelper();
$helper->boot('front');
-$t = new lime_test(17);
+$t = new lime_test(18);
$forms = $helper->get('form_manager');
@@ -50,6 +50,10 @@
$expected = '<div class="dm_help_wrap">username help</div>';
$t->is($got, $expected, $got);
+$got = (string)$form['username']->help('another help');
+$expected = '<div class="dm_help_wrap">another help</div>';
+$t->is($got, $expected, $got);
+
$got = (string)$form['username']->error();
$expected = '';
$t->is($got, $expected, $got);
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.