/** * Add items to the bridge, and remove them from the items array * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param string $element1 * * @return void */ protected function addItems(\MUtil_Model_Bridge_FormBridgeInterface $bridge, $element1) { $args = func_get_args(); if (count($args) < 2) { throw new \Gems_Exception_Coding('Use at least 2 arguments, first the bridge and then one or more individual items'); } array_shift($args); // Remove bridge $elements = \MUtil_Ra::flatten($args); $model = $this->getModel(); //Remove the elements from the _items variable $this->_items = array_diff($this->_items, $elements); //And add them to the bridge foreach ($elements as $name) { if ($model->has($name, 'label') || $model->has($name, 'elementClass')) { $bridge->add($name); } else { $bridge->addHidden($name); } } }
/** * Adds elements from the model to the bridge that creates the form. * * Overrule this function to add different elements to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model */ protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { if (!$this->createData) { $bridge->addHidden('gtr_id_track'); } $bridge->addText('gtr_track_name'); // gtr_track_class if ($this->trackEngine) { $options = $model->get('gtr_track_class', 'multiOptions'); $alternatives = $this->trackEngine->getConversionTargets($options); if (count($alternatives) > 1) { $options = $alternatives; $bridge->addHidden($this->_oldClassName); if (!isset($this->formData[$this->_oldClassName])) { $this->formData[$this->_oldClassName] = $this->formData['gtr_track_class']; } $classEdit = true; } else { $classEdit = false; } } else { $tracker = $this->loader->getTracker(); $options = $tracker->getTrackEngineList(true, true); $classEdit = true; } $model->set('gtr_track_class', 'multiOptions', $options, 'escape', false); if ($classEdit) { $bridge->addRadio('gtr_track_class'); } else { $bridge->addExhibitor('gtr_track_class'); } $bridge->addDate('gtr_date_start'); $bridge->addDate('gtr_date_until'); if (!$this->createData) { $bridge->addCheckbox('gtr_active'); } if ($model->has('gtr_code')) { $bridge->addText('gtr_code'); } if ($model->has('gtr_calculation_event', 'label')) { $bridge->add('gtr_calculation_event'); } if ($model->has('gtr_completed_event', 'label')) { $bridge->add('gtr_completed_event'); } if ($model->has('gtr_beforefieldupdate_event', 'label')) { $bridge->add('gtr_beforefieldupdate_event'); } if ($model->has('gtr_fieldupdate_event', 'label')) { $bridge->add('gtr_fieldupdate_event'); } $bridge->add('gtr_organizations'); if (\MUtil_Bootstrap::enabled()) { $element = new \MUtil_Bootstrap_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=gtr_organizations]')); } else { $element = new \Gems_JQuery_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=gtr_organizations]')); } $element->setLabel($this->_('Toggle')); $bridge->addElement($element); }
/** * Adds elements from the model to the bridge that creates the form. * * Overrule this function to add different elements to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model * @param array $data The data that will later be loaded into the form * @param optional boolean $new Form should be for a new element * @return void|array When an array of new values is return, these are used to update the $data array in the calling function */ protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model, array $data, $new = false) { foreach ($model->getItemsOrdered() as $name) { if ($model->has($name, 'label') || $model->has($name, 'elementClass')) { $bridge->add($name); } else { $bridge->addHidden($name); } } }