From: <gem...@li...> - 2012-01-06 14:09:26
|
Revision: 403 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=403&view=rev Author: mennodekker Date: 2012-01-06 14:09:20 +0000 (Fri, 06 Jan 2012) Log Message: ----------- reverting #400 and committing other fix for the same problem Modified Paths: -------------- trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php trunk/library/snippets/Organization/OrganizationEditSnippet.php Modified: trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php =================================================================== --- trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2012-01-06 14:02:50 UTC (rev 402) +++ trunk/library/classes/MUtil/Snippets/ModelFormSnippetAbstract.php 2012-01-06 14:09:20 UTC (rev 403) @@ -157,10 +157,10 @@ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model) { //Get all elements in the model if not already done - $this->initItems($model); + $this->initItems(); //And any remaining item - $this->addItems($bridge, $model, $this->_items); + $this->addItems($bridge, $this->_items); } /** @@ -171,22 +171,22 @@ * * @return void */ - protected function addItems(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model, $element1) + protected function addItems(MUtil_Model_FormBridge $bridge, $element1) { $args = func_get_args(); - if (count($args) < 3) { - throw new Gems_Exception_Coding('Use at least 3 arguments; bridge, model and then one or more individual items'); + if (count($args)<2) { + throw new Gems_Exception_Coding('Use at least 2 arguments, first the bridge and then one or more idividual items'); } $bridge = array_shift($args); - $model = array_shift($args); $elements = MUtil_Ra::flatten($args); //Remove the elements from the _items variable $this->_items = array_diff($this->_items, $elements); - + //And add them to the bridge foreach($elements as $name) { + $model = $this->getModel(); if ($label = $model->get($name, 'label')) { $bridge->add($name); } else { @@ -362,9 +362,10 @@ /** * Initialize the _items variable to hold all items from the model */ - protected function initItems(MUtil_Model_ModelAbstract $model) + protected function initItems() { if (is_null($this->_items)) { + $model = $this->getModel(); $this->_items = $model->getItemsOrdered(); } } @@ -549,4 +550,4 @@ // Note we use an MUtil_Form return $this->_form->isValid($this->formData, $this->disableValidatorTranslation); } -} +} \ No newline at end of file Modified: trunk/library/snippets/Organization/OrganizationEditSnippet.php =================================================================== --- trunk/library/snippets/Organization/OrganizationEditSnippet.php 2012-01-06 14:02:50 UTC (rev 402) +++ trunk/library/snippets/Organization/OrganizationEditSnippet.php 2012-01-06 14:09:20 UTC (rev 403) @@ -64,7 +64,7 @@ protected function addFormElements(MUtil_Model_FormBridge $bridge, MUtil_Model_ModelAbstract $model) { //Get all elements in the model if not already done - $this->initItems($model); + $this->initItems(); //Create our tab structure first check if tab already exists to allow extension if (!($bridge->getTab('general'))) { @@ -72,17 +72,17 @@ } //Need the first two together for validation $bridge->addHtml('org')->b($this->_('Organization')); - $this->addItems($bridge, $model, 'gor_name', 'gor_id_organization', 'gor_location', 'gor_url', 'gor_active'); + $this->addItems($bridge, 'gor_name', 'gor_id_organization', 'gor_location', 'gor_url', 'gor_active'); $bridge->addHtml('contact')->b($this->_('Contact')); $bridge->addHtml('contact_desc')->i($this->_('The contact details for this organization, used for emailing.')); - $this->addItems($bridge, $model, 'gor_contact_name', 'gor_contact_email'); + $this->addItems($bridge, 'gor_contact_name', 'gor_contact_email'); $bridge->addHtml('general_other')->b($this->_('Other')); - $this->addItems($bridge, $model, 'gor_iso_lang', 'gor_code', 'gor_has_respondents'); + $this->addItems($bridge, 'gor_iso_lang', 'gor_code', 'gor_has_respondents'); if (!($bridge->getTab('email'))) { $bridge->addTab('email', 'value', $this->_('Email') . ' & ' . $this->_('Token')); } - $this->addItems($bridge, $model, 'gor_welcome', 'gor_signature'); + $this->addItems($bridge, 'gor_welcome', 'gor_signature'); if (!($bridge->getTab('access'))) { $bridge->addTab('access', 'value', $this->_('Access')); @@ -94,7 +94,7 @@ unset($multiOptions[$this->formData['gor_id_organization']]); $model->set('gor_accessible_by', 'multiOptions', $multiOptions); } - $this->addItems($bridge, $model, 'gor_has_login', 'gor_add_respondents', 'gor_respondent_group', 'gor_accessible_by'); + $this->addItems($bridge, 'gor_has_login', 'gor_add_respondents', 'gor_respondent_group', 'gor_accessible_by'); //Show what organizations we can access if (isset($this->formData['gor_id_organization']) && !empty($this->formData['gor_id_organization'])) { @@ -106,7 +106,7 @@ $bridge->addExhibitor('allowed', 'value', $display, 'label', $this->_('Can access')); } - $this->addItems($bridge, $model, 'gor_user_class'); + $this->addItems($bridge, 'gor_user_class'); if (isset($this->formData['gor_user_class']) && !empty($this->formData['gor_user_class'])) { $class = $this->formData['gor_user_class'] . 'Definition'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |