Skip to content
Browse files

clean up of CForm.

  • Loading branch information...
1 parent 4f61ea4 commit e698c94ffb4831e3f8787a3d288c2c966c30f195 qiang.xue committed
Showing with 7 additions and 24 deletions.
  1. +3 −24 framework/web/form/CForm.php
  2. +4 −0 framework/web/form/CFormElementCollection.php
View
27 framework/web/form/CForm.php
@@ -107,7 +107,6 @@ class CForm extends CFormElement implements ArrayAccess
private $_model;
private $_elements;
private $_buttons;
- private $_hiddens=array();
/**
* Constructor.
@@ -334,24 +333,6 @@ public function setButtons($buttons)
}
/**
- * Returns the hidden elements of this form.
- * The hidden elements are obtained from {@link elements} collection.
- * Only the currently "renderable" elements are returned.
- * @return array the "renderable" hidden elements of this form.
- */
- public function getHiddenElements()
- {
- $model=$this->getModel();
- $elements=array();
- foreach($this->_hiddens as $name=>$element)
- {
- if($model->isAttributeSafe($name))
- $elements[$name]=$element;
- }
- return $elements;
- }
-
- /**
* Renders the form.
* The default implementation simply calls {@link renderBegin}, {@link renderBody} and {@link renderEnd}.
* @return string the rendering result
@@ -477,12 +458,11 @@ public function renderElement($element)
* This method is called after an element is added to the element collection.
* @param string the name of the element
* @param CFormElement the element that is added
- * @param boolean whether the element is added to the {@link buttons} collection
+ * @param boolean whether the element is added to the {@link buttons} collection.
+ * If false, it means the element is added to the {@link elements} collection.
*/
public function addedElement($name,$element,$forButtons)
{
- if($element instanceof CFormInputElement && $element->type==='hidden')
- $this->_hiddens[$name]=$element;
}
/**
@@ -490,11 +470,10 @@ public function addedElement($name,$element,$forButtons)
* @param string the name of the element
* @param CFormElement the element that is removed
* @param boolean whether the element is removed from the {@link buttons} collection
+ * If false, it means the element is removed from the {@link elements} collection.
*/
public function removedElement($name,$element,$forButtons)
{
- if($element instanceof CFormInputElement && $element->type==='hidden')
- unset($this->_hiddens[$name]);
}
/**
View
4 framework/web/form/CFormElementCollection.php
@@ -100,6 +100,10 @@ public function add($key,$value)
$this->_form->addedElement($key,$element,$this->_forButtons);
}
+ /**
+ * Removes the specified element by key.
+ * @param string the name of the element to be removed from the collection
+ */
public function remove($key)
{
if($this->exists($key))

0 comments on commit e698c94

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