[commits] [Wiki] changed: Doc/Dev/FormPackage

2021-03-10 Thread Ralf Lang (B1 Systems GmbH)

rlang  Wed, 10 Mar 2021 17:32:01 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  20
Change log:  fixes

@@ -234,29 +234,37 @@
 Construct & pass dependencies. There should be no reason for a singleton.
 Fix:

 +++ inheritance + method signature mismatch
--
+- Form_Type's init() pseudo constructor
+
 Fix:
+- Use proper constructors
+- Provide a builder with a fluent interface?

 +++ inconsistent class names
 - lowercase field types
-Fix:
+Fix:
+- Namespaces and structured class names

 +++ Internally uses the Horde:: shortcuts (separate package, hard to test)
-Fix:
+Fix:

 +++ Multiple classes in one file
 - Most field types are attached to the Horde_Form_Type base package.
 Fix:
-
-+++ Extensive use of reference signatures
-Fix:
+
+- one class per file
+
 Extensive use of reference signatures
+Fix: Check if we really need these.

 +++ hard-coupled javascript
 - parts rely on scriptaculous and hence prototypjs
 - parts rely on redboxjs
 Fix:
+
+- check if we can factor out the JS

 +++ Uses globals
 - registry
 - injector

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/FormPackage

2021-03-10 Thread Ralf Lang (B1 Systems GmbH)

rlang  Wed, 10 Mar 2021 17:17:41 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  19
Change log:  autowire

@@ -265,4 +265,9 @@

 +++ uses var keyword

 - At least in renderer
+
 Autowire-unfriendly constructors
+
+- untyped variables and array parameters
+

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/FormPackage

2021-03-10 Thread Ralf Lang (B1 Systems GmbH)

rlang  Wed, 10 Mar 2021 17:12:43 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  18
Change log:  var keyword

@@ -261,4 +261,8 @@
 - registry
 - injector
 - session
 - browser
+
 uses var keyword
+
+- At least in renderer

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/FormPackage

2021-03-10 Thread Ralf Lang (B1 Systems GmbH)

rlang  Wed, 10 Mar 2021 17:10:37 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  17
Change log:  uses globals

@@ -256,4 +256,9 @@
 - parts rely on scriptaculous and hence prototypjs
 - parts rely on redboxjs
 Fix:

 Uses globals
+- registry
+- injector
+- session
+- browser

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/FormPackage

2021-03-10 Thread Ralf Lang (B1 Systems GmbH)

rlang  Wed, 10 Mar 2021 16:07:23 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  16
Change log:  Document some structural issues to address.

@@ -218,4 +218,42 @@
 print_r($info);
 echo '';
 }
 
+
+
+++ Horde_Form design issues
+
 Constructors
+
+some PHP 4 constructors are left
+
+Fix:
+
 singletons
+
+Construct & pass dependencies. There should be no reason for a singleton.
+Fix:
+
 inheritance + method signature mismatch
+-
+Fix:
+
 inconsistent class names
+- lowercase field types
+Fix:
+
 Internally uses the Horde:: shortcuts (separate package, hard to test)
+Fix:
+
 Multiple classes in one file
+- Most field types are attached to the Horde_Form_Type base package.
+Fix:
+
 Extensive use of reference signatures
+Fix:
+
 hard-coupled javascript
+- parts rely on scriptaculous and hence prototypjs
+- parts rely on redboxjs
+Fix:
+

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/FormPackage

2016-09-22 Thread Wiki Guest

guest [80.153.12.208]  Thu, 22 Sep 2016 14:04:48 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  15
Change log:  fixed minor issues

@@ -35,15 +35,11 @@
 Here are some examples for introducing features of Horde_Forms:

 

+A simple form to get started.

 
-// Require and set up Horde_Form.
-require_once 'Horde/Form.php';
-require_once 'Horde/Form/Renderer.php';
-require_once 'Horde/Variables.php';
-
 // Example 1: a simple form

 // Set up this data as a new Horde_Form_Vars object.
 $vars = Horde_Variables::getDefaultVariables();

--
commits mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: commits-unsubscr...@lists.horde.org


[commits] [Wiki] changed: Doc/Dev/FormPackage

2016-09-22 Thread Wiki Guest

guest [80.153.12.208]  Thu, 22 Sep 2016 14:03:07 +

Modified page: https://wiki.horde.org/Doc/Dev/FormPackage
New Revision:  14
Change log:  updated examples, introduced page code as environment for  
examples


@@ -8,44 +8,76 @@

 ++ Filling a form with values

 The following code could be used to fill a form through Horde_Form,  
for example to edit a record. The example is a bit abstracted from  
reality, in that you would also need to build some validation around  
this code, checking for a form submission, etc. to eventually have a  
useable form.

+
+For using the below examples, consider Horde application "myapp" with  
page "form.php":

+
+
+header(array(
+'title' => _("My Page"),
+));
+
+//
+// Example code goes here
+//
+
+$page_output->footer();
+
+
+
+
+
+Here are some examples for introducing features of Horde_Forms:
+
+
+

 
-/* Require and set up Horde_Form. */
+// Require and set up Horde_Form.
 require_once 'Horde/Form.php';
 require_once 'Horde/Form/Renderer.php';
 require_once 'Horde/Variables.php';

-/* Set up this data as a new Horde_Form_Vars object. */
-$vars = Variables::getDefaultVariables();
+// Example 1: a simple form
+
+// Set up this data as a new Horde_Form_Vars object.
+$vars = Horde_Variables::getDefaultVariables();
 if (!$vars->exists('example_foo')) {
 $vars->set('example_foo', 'Foo Sample Data');
 }

-/* Get formname var to check if submitted later on. */
+// Get formname var to check if submitted later on.
 $formname = $vars->get('formname');

-/* Get the form object, setting the vars and the title. */
+// Get the form object, setting the vars and the title.
 $myform = new Horde_Form($vars, _("An Example Form"), 'some_form');

-/* Set up the form fields. */
+// Set up the form fields.
 $myform->addHidden('', 'example_hidden', 'int', false);
 $myform->addVariable(_("Foo field"), 'example_foo', 'text', true);
 $myform->addVariable(_("Bar field"), 'example_bar', 'longtext',  
true, false, _("You have to fill in some long text here"), array(4,  
40));
+$myform->addVariable(_("Make editable"), 'example_edit',  
'monthdayyear', false);

+$myform->setButtons('Abschicken', true);

-/* Check if form submitted and validate. */
+// Check if form submitted and validate.
 if ($formname) {
 if ($myform->validate($vars)) {
 $myform->getInfo($vars, $info);

-/* Do something with this form data. */
+// Do something with this form data.
 echo 'saving data';
 }
 }

-/* Render out the form. */
-$myform->renderActive(new Horde_Form_Renderer(), $vars, 'edit.php', 'post');
+// Render out the form.
+$myform->renderActive(new Horde_Form_Renderer(), $vars, 'form.php', 'post');
+
 

 

@@ -53,92 +85,79 @@

 Here's an example that uses the conditional_enable action to enable  
a text description if the user picks "Other".


 
-/**
- * Example for the conditional_enable action.
- */
+// Example 2: conditional enable

-@define('HORDE_BASE', dirname(__FILE__));
-require_once HORDE_BASE . '/lib/core.php';
-require_once 'Horde/Form.php';
-require_once 'Horde/Form/Action.php';
-require_once 'Horde/Form/Renderer.php';
-require_once 'Horde/Variables.php';
-
-$registry = &Registry::singleton();
-
-$vars = Variables::getDefaultVariables();
-$form = new Horde_Form($vars, 'Using conditional enable');
+$vars = Horde_Variables::getDefaultVariables();
+$myform = new Horde_Form($vars, 'Using conditional enable');

 $choices = array('big' => 'BIG',
  'small' => 'small',
  'other' => 'Other');
-$form->addVariable('Select something', 'choices', 'enum', true,  
false, '', array($choices, true));
-$o = &$form->addVariable('If other, please describe', 'other_text',  
'text', false, false);

-$params = array('target' => 'choices',
-'enabled' => true,
-'values' => array('other'));
-$o->setAction(Horde_Form_Action::factory('conditional_enable', $params));
+$myform->addVariable('Select something', 'choices', 'enum', true,  
false, '', array($choices, true));
+$o = &$myform->addVariable('If other, please describe', 'other_text',  
'text', false, false);


-/* Render the form. */
-$form->renderActive(new Horde_Form_Renderer(), $vars, 'form.php', 'post');
+// $o is a Horde_Form_Variable
+$params = array('target' => 'choices',// variable name on  
which the enable state depends
+'values' => array('other'), // values of target on  
which to change state
+'enabled' => true);// state if variable  
contains one of the values

+// assign an action to the variable
+$o->setAction(Horde_Form_Action::factory('ConditionalEnable', $params));
+// action defined through Horde_Form_Action_ class
+
+// Render out the form.
+$myform->renderActive(new Horde_Form_Renderer(), $vars, 'form.php', 'post');
 

 

-
-require_once 'Horde/Form.php';
-require_once 'Horde/Variables.php';
-require_once 'Horde/Form/Renderer.php';
-
-$vars = Variables::getDefaultVariables();
+
+/