Skip to content

Commit

Permalink
mark required fields in form with *
Browse files Browse the repository at this point in the history
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
Nils Georg Heinrich Reichert authored and adrianheine committed May 19, 2011
1 parent 0fbf59c commit 195e190
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
14 changes: 1 addition & 13 deletions action.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,19 +16,7 @@
require_once(DOKU_PLUGIN.'action.php'); require_once(DOKU_PLUGIN.'action.php');


class action_plugin_bureaucracy extends DokuWiki_Action_Plugin { 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) { function register(&$controller) {
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this,
Expand Down
1 change: 0 additions & 1 deletion actions/action.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ function run($data, $thanks, $argv){
return false; return false;
} }
} }
// vim:ts=4:sw=4:et:enc=utf-8:
3 changes: 3 additions & 0 deletions fields/field.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function render($params, $form) {
} }


$params = array_merge($this->opt, $params); $params = array_merge($this->opt, $params);
if(!isset($this->opt['optional'])) {
$params["label"].=" *";
}
$form->addElement($this->_parse_tpl($this->tpl, $params)); $form->addElement($this->_parse_tpl($this->tpl, $params));
} }


Expand Down
6 changes: 6 additions & 0 deletions fields/static.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
class syntax_plugin_bureaucracy_field_static extends syntax_plugin_bureaucracy_field { class syntax_plugin_bureaucracy_field_static extends syntax_plugin_bureaucracy_field {
var $tpl = '<p>@@LABEL@@</p>'; 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) { function handle_post($param) {
return true; return true;
} }
Expand Down
6 changes: 6 additions & 0 deletions fields/submit.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ class syntax_plugin_bureaucracy_field_submit extends syntax_plugin_bureaucracy_f
static $captcha_displayed = false; static $captcha_displayed = false;
static $captcha_checked = 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) { function render($params, $form) {
if(!syntax_plugin_bureaucracy_field_submit::$captcha_displayed){ if(!syntax_plugin_bureaucracy_field_submit::$captcha_displayed){
syntax_plugin_bureaucracy_field_submit::$captcha_displayed = true; syntax_plugin_bureaucracy_field_submit::$captcha_displayed = true;
Expand Down
2 changes: 0 additions & 2 deletions syntax.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -238,5 +238,3 @@ function _sanitizeClassName($classname) {
return preg_replace('/[^\w\x7f-\xff]/', '', strtolower($classname)); return preg_replace('/[^\w\x7f-\xff]/', '', strtolower($classname));
} }
} }

//Setup VIM: ex: et ts=4 enc=utf-8 :

3 comments on commit 195e190

@pletiplot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@aetherfaerber
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@benat
Copy link

@benat benat commented on 195e190 May 16, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.