[tipos commit] r1593 - in branches/FreeForm/Solar/View: . Helper

1 view
Skip to first unread message

codesite...@google.com

unread,
Sep 25, 2008, 3:23:30 PM9/25/08
to tipo...@googlegroups.com
Author: rodrigo.moraes
Date: Thu Sep 25 12:23:07 2008
New Revision: 1593

Added:
branches/FreeForm/Solar/View/
branches/FreeForm/Solar/View/Helper/
branches/FreeForm/Solar/View/Helper/FormElement.php (contents, props
changed)

Log:
Added Solar_View_Form_Element as it is required that it works with elements
as objects as well.

Added: branches/FreeForm/Solar/View/Helper/FormElement.php
==============================================================================
--- (empty file)
+++ branches/FreeForm/Solar/View/Helper/FormElement.php Thu Sep 25 12:23:07
2008
@@ -0,0 +1,163 @@
+<?php
+/**
+ *
+ * Abstract helper for form elements.
+ *
+ * @category Solar
+ *
+ * @package Solar_View_Helper_Form
+ *
+ * @author Paul M. Jones <pmj...@solarphp.com>
+ *
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ *
+ * @version $Id$
+ *
+ */
+abstract class Solar_View_Helper_FormElement extends Solar_View_Helper {
+
+ /**
+ *
+ * Default form element information.
+ *
+ * @var array
+ *
+ */
+ protected $_info = array(
+ 'type' => '',
+ 'name' => '',
+ 'value' => '',
+ 'label' => '',
+ 'attribs' => '',
+ 'options' => array(),
+ 'require' => false,
+ 'disable' => false,
+ 'invalid' => array(),
+ );
+
+ /**
+ *
+ * The order in which to process info keys.
+ *
+ * Attribs is last so that attributes are unset properly.
+ *
+ * @var array
+ *
+ */
+ protected $_keys = array(
+ 'type',
+ 'name',
+ 'value',
+ 'label',
+ 'options',
+ 'require',
+ 'disable',
+ 'invalid',
+ 'attribs',
+ );
+
+ /**
+ *
+ * The form element type (text, radio, etc).
+ *
+ * @var string
+ *
+ */
+ protected $_type;
+
+ /**
+ *
+ * The form element name.
+ *
+ * @var string
+ *
+ */
+ protected $_name;
+
+
+ /**
+ *
+ * The form element value.
+ *
+ * @var string
+ *
+ */
+ protected $_value;
+
+ /**
+ *
+ * The form element label.
+ *
+ * @var string
+ *
+ */
+ protected $_label;
+
+ /**
+ *
+ * The form element attributes (checked, selected, readonly, etc).
+ *
+ * @var array
+ *
+ */
+
+ protected $_attribs;
+
+ /**
+ *
+ * Options for checkbox, select, and radio elements.
+ *
+ * @var array
+ *
+ */
+ protected $_options;
+
+ /**
+ *
+ * Whether or not the element is required.
+ *
+ * @var bool
+ *
+ */
+ protected $_require;
+
+ /**
+ *
+ * Whether or not the element is to be disabled.
+ *
+ * @var bool
+ *
+ */
+ protected $_disable;
+
+ /**
+ *
+ * Feedback messages for the element.
+ *
+ * @var bool
+ *
+ */
+ protected $_invalid;
+
+ /**
+ *
+ * Prepares an info array and imports to the properties.
+ *
+ * @param array|Solar_Form_Element $spec An element object or an array
of
+ * element information.
+ *
+ * @return void
+ *
+ */
+ protected function _prepare($spec)
+ {
+ if (! $spec instanceof Solar_Form_Element) {
+ $spec = Solar::factory('Solar_Form_Element')->load($spec);
+ }
+
+ foreach ($this->_keys as $key) {
+ $prop = "_$key";
+ $this->$prop = $spec[$key];
+ }
+ }
+}

Reply all
Reply to author
Forward
0 new messages