anewt-developers team mailing list archive
-
anewt-developers team
-
Mailing list archive
-
Message #00231
[Branch ~uws/anewt/anewt.uws] Rev 1766: [form] Support autocomplete property; improve id generation
------------------------------------------------------------
revno: 1766
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt.uws
timestamp: Wed 2010-02-24 21:50:42 +0100
message:
[form] Support autocomplete property; improve id generation
AnewtForm now has an optional 'autocomplete' property
(defaulting to null) to control the inclusion of an
"autocomplete=on|off" attribute on the <form> element. While
not a W3 standard, this is supported by the major browsers.
Additionally, the default form id generation logic has
slightly improved: it only includes ids by default for
custom forms (classes extending AnewtForm instead of using
it directly).
modified:
form/form.lib.php
form/renderer/base.lib.php
--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws
Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription.
=== modified file 'form/form.lib.php'
--- form/form.lib.php 2009-08-02 16:32:09 +0000
+++ form/form.lib.php 2010-02-24 20:50:42 +0000
@@ -66,16 +66,22 @@
*/
function __construct()
{
- /* Default values */
- $id = sprintf('form-%s', str_strip_suffix(strtolower(get_class($this)), 'form'));
$this->_seed(array(
- 'id' => $id,
- 'method' => ANEWT_FORM_METHOD_POST,
- 'action' => AnewtRequest::relative_url(),
-
- 'description' => null,
- 'error' => null,
+ 'method' => ANEWT_FORM_METHOD_POST,
+ 'action' => AnewtRequest::relative_url(),
+
+ 'description' => null,
+ 'error' => null,
+
+ 'autocomplete' => null,
));
+
+ /* Automatic id for classes extending AnewtForm */
+ $class_name = get_class($this);
+ if ($class_name != 'AnewtForm')
+ {
+ $this->id = sprintf('form-%s', str_strip_suffix(strtolower($class_name), 'form'));
+ }
}
=== modified file 'form/renderer/base.lib.php'
--- form/renderer/base.lib.php 2009-07-21 18:54:20 +0000
+++ form/renderer/base.lib.php 2010-02-24 20:50:42 +0000
@@ -87,6 +87,16 @@
$attributes['class'] = $this->_form->_get('class');
+ /* Explicitly enable/disable autocomplete (not a W3 standard) */
+
+ $autocomplete = $this->_form->autocomplete;
+ if (!is_null($autocomplete))
+ {
+ assert('is_bool($autocomplete)');
+ $attributes['autocomplete'] = ($autocomplete ? 'on' : 'off');
+ }
+
+
/* Output <form> element with all hidden elements */
$form = new AnewtXHTMLForm(null, $attributes);