Skip to content
Browse files

mark required fields in form with *

also exlude static and submit fields from being marked as required by setting them to be always optional.
some code cleanup as well
  • Loading branch information...
1 parent 0fbf59c commit 195e190d95ddd6ee5078bf3112bb2a77662b8c21 Nils Georg Heinrich Reichert committed with adrianheine May 19, 2011
Showing with 16 additions and 16 deletions.
  1. +1 −13 action.php
  2. +0 −1 actions/action.php
  3. +3 −0 fields/field.php
  4. +6 −0 fields/static.php
  5. +6 −0 fields/submit.php
  6. +0 −2 syntax.php
View
14 action.php
@@ -16,19 +16,7 @@
require_once(DOKU_PLUGIN.'action.php');
class action_plugin_bureaucracy extends DokuWiki_Action_Plugin {
- /**
- * return some info
- */
- function getInfo(){
- return array(
- 'author' => 'Andreas Gohr',
- 'email' => 'andi@splitbrain.org',
- 'date' => '2009-08-16',
- 'name' => 'Bureaucracy Plugin',
- 'desc' => 'A simple form generator/emailer',
- 'url' => 'http://dokuwiki.org/plugin:bureaucracy',
- );
- }
+
function register(&$controller) {
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this,
View
1 actions/action.php
@@ -30,4 +30,3 @@ function run($data, $thanks, $argv){
return false;
}
}
-// vim:ts=4:sw=4:et:enc=utf-8:
View
3 fields/field.php
@@ -108,6 +108,9 @@ function render($params, $form) {
}
$params = array_merge($this->opt, $params);
+ if(!isset($this->opt['optional'])) {
+ $params["label"].=" *";
+ }
$form->addElement($this->_parse_tpl($this->tpl, $params));
}
View
6 fields/static.php
@@ -2,6 +2,12 @@
class syntax_plugin_bureaucracy_field_static extends syntax_plugin_bureaucracy_field {
var $tpl = '<p>@@LABEL@@</p>';
+ function __construct($args) {
+ parent::__construct($args);
+ // make always optional to prevent being marked as required
+ $this->opt['optional'] = true;
+ }
+
function handle_post($param) {
return true;
}
View
6 fields/submit.php
@@ -4,6 +4,12 @@ class syntax_plugin_bureaucracy_field_submit extends syntax_plugin_bureaucracy_f
static $captcha_displayed = false;
static $captcha_checked = false;
+ function __construct($args) {
+ parent::__construct($args);
+ // make always optional to prevent being marked as required
+ $this->opt['optional'] = true;
+ }
+
function render($params, $form) {
if(!syntax_plugin_bureaucracy_field_submit::$captcha_displayed){
syntax_plugin_bureaucracy_field_submit::$captcha_displayed = true;
View
2 syntax.php
@@ -238,5 +238,3 @@ function _sanitizeClassName($classname) {
return preg_replace('/[^\w\x7f-\xff]/', '', strtolower($classname));
}
}
-
-//Setup VIM: ex: et ts=4 enc=utf-8 :

3 comments on commit 195e190

@pletiplot

These big updates shoud be recorded in info file for proper updating via plugin manager.

@aetherfaerber
Collaborator

You're absolutely correct.
Did this in 5883d58.
Thanks for the pointer.

@benat
benat commented on 195e190 May 16, 2012

I don't think marking required fields in the form with a " * " is a good idea: this is a presentation matter and it should be left to the wiki developer as some people will want to mark required fields with a different color, or with strong characters, etc. Sorry if this is not the right place to make such a comment, please let me know.

Please sign in to comment.
Something went wrong with that request. Please try again.