/**
  * @return string
  */
 protected function renderAttributeIndexOrDerivedType()
 {
     $hiddenInputName = Element::resolveInputNamePrefixIntoString(array_merge($this->inputPrefixData, array('attributeIndexOrDerivedType')));
     $hiddenInputId = Element::resolveInputIdPrefixIntoString(array_merge($this->inputPrefixData, array('attributeIndexOrDerivedType')));
     $idInputHtmlOptions = array('id' => $hiddenInputId);
     return ZurmoHtml::hiddenField($hiddenInputName, $this->model->getAttributeIndexOrDerivedType(), $idInputHtmlOptions);
 }
 /**
  * @return array
  */
 protected function resolveItemsAndContent()
 {
     $items = array();
     $inputName = Element::resolveInputNamePrefixIntoString(array('SavedWorkflow', 'savedWorkflowIds'));
     foreach ($this->savedWorkflows as $workflow) {
         $content = '<div class="dynamic-row">';
         $content .= ZurmoHtml::hiddenField($inputName . '[]', $workflow->id);
         $content .= strval($workflow);
         $content .= '</div>';
         $items[] = array('content' => $content);
     }
     return $items;
 }
Beispiel #3
0
 public static function renderDynamicSearchAttributeInput($viewClassName, $modelClassName, $formModelClassName, $rowNumber, $attributeIndexOrDerivedType, $searchAttributes = array(), $suffix = null)
 {
     assert('is_string($viewClassName)');
     assert('is_string($modelClassName)');
     assert('is_string($formModelClassName)');
     assert('is_int($rowNumber)');
     assert('is_string($attributeIndexOrDerivedType) || $attributeIndexOrDerivedType == null');
     assert('is_array($searchAttributes)');
     assert('is_string($suffix) || $suffix == null');
     $content = null;
     if (count(explode(FormModelUtil::RELATION_DELIMITER, $attributeIndexOrDerivedType)) > 1) {
         $model = new $modelClassName(false);
         $nestedAttributes = explode(FormModelUtil::RELATION_DELIMITER, $attributeIndexOrDerivedType);
         $inputPrefix = array($formModelClassName, DynamicSearchForm::DYNAMIC_NAME, $rowNumber);
         $totalNestedCount = count($nestedAttributes);
         $processCount = 1;
         $nestedSearchAttributes = $searchAttributes;
         foreach ($nestedAttributes as $attribute) {
             if ($processCount < $totalNestedCount && isset($nestedSearchAttributes[$attribute])) {
                 $nestedSearchAttributes = $nestedSearchAttributes[$attribute];
                 if (isset($nestedSearchAttributes['relatedData'])) {
                     unset($nestedSearchAttributes['relatedData']);
                 }
             }
             if ($processCount < $totalNestedCount) {
                 $model = SearchUtil::resolveModelToUseByModelAndAttributeName($model, $attribute);
                 $inputPrefix[] = $attribute;
                 $relatedDataName = Element::resolveInputNamePrefixIntoString($inputPrefix) . '[relatedData]';
                 $content .= ZurmoHtml::hiddenField($relatedDataName, true);
             }
             $processCount++;
         }
         $attributeIndexOrDerivedType = $attribute;
         $modelToUse = $model;
         $modelToUse->setAttributes($nestedSearchAttributes);
         $cellElementModelClassName = get_class($model->getModel());
         //Dynamic Search needs to always assume there is an available SearchForm
         //Always assumes the SearchView to use matches the exact pluralCamelCasedName.
         //Does not support nested relations to leads persay.  It will resolve as a Contact.
         //This is not a problem since you can't relate a model to a lead, it is related to a contact.
         //So this scenario would not come up naturally.
         $moduleClassName = $model->getModel()->getModuleClassName();
         $viewClassName = $moduleClassName::getPluralCamelCasedName() . 'SearchView';
         $element = DynamicSearchUtil::getCellElement($viewClassName, $cellElementModelClassName, $attributeIndexOrDerivedType);
     } else {
         $model = new $modelClassName(false);
         $model->setScenario('importModel');
         //this is so attributes such as modified user can be set
         $modelToUse = new $formModelClassName($model);
         $modelToUse->setAttributes($searchAttributes);
         $inputPrefix = array($formModelClassName, DynamicSearchForm::DYNAMIC_NAME, $rowNumber);
         $element = DynamicSearchUtil::getCellElement($viewClassName, $modelClassName, $attributeIndexOrDerivedType);
     }
     $form = new NoRequiredsActiveForm();
     $form->id = "search-form";
     $element['inputPrefix'] = $inputPrefix;
     $elementclassname = $element['type'] . 'Element';
     $element = new $elementclassname($modelToUse, $element['attributeName'], $form, array_slice($element, 2));
     $element->editableTemplate = '{content}{error}';
     $content .= $element->render();
     DropDownUtil::registerScripts(CClientScript::POS_END);
     return $content;
 }
 /**
  * @return string
  */
 protected function renderHiddenStructurePositionInput()
 {
     $hiddenInputName = Element::resolveInputNamePrefixIntoString(array_merge($this->inputPrefixData, array('structurePosition')));
     $hiddenInputId = Element::resolveInputIdPrefixIntoString(array_merge($this->inputPrefixData, array('structurePosition')));
     $idInputHtmlOptions = array('id' => $hiddenInputId, 'class' => 'structure-position');
     return ZurmoHtml::hiddenField($hiddenInputName, $this->rowNumber + 1, $idInputHtmlOptions);
 }
 /**
  * Builds hidden operator input. Used in the event there is only one operator available. No reason to show
  * that in the user interface
  * @return string
  */
 protected function renderHiddenOperator()
 {
     if ($this->model->hasAvailableOperatorsType() && count($this->model->getOperatorValuesAndLabels()) == 1) {
         $hiddenInputName = Element::resolveInputNamePrefixIntoString(array_merge($this->inputPrefixData, array('operator')));
         $hiddenInputId = Element::resolveInputIdPrefixIntoString(array_merge($this->inputPrefixData, array('operator')));
         $idInputHtmlOptions = array('id' => $hiddenInputId);
         $valuesAndLabels = $this->model->getOperatorValuesAndLabels();
         return ZurmoHtml::hiddenField($hiddenInputName, key($valuesAndLabels), $idInputHtmlOptions);
     }
 }
 /**
  * @return string
  */
 protected function renderHiddenRecipientsInputForValidationContent()
 {
     $hiddenInputId = Element::resolveInputIdPrefixIntoString(array_merge($this->inputPrefixData, array('recipientsValidation')));
     $hiddenInputName = Element::resolveInputNamePrefixIntoString(array_merge($this->inputPrefixData, array('recipientsValidation')));
     $idInputHtmlOptions = array('id' => $hiddenInputId);
     $id = Element::resolveInputIdPrefixIntoString(array_merge($this->inputPrefixData, array('recipientsValidation')));
     $content = ZurmoHtml::hiddenField($hiddenInputName, null, $idInputHtmlOptions);
     $content .= $this->form->error($this->model, 'recipientsValidation', array('inputID' => $hiddenInputId), true, true, $id);
     return $content;
 }
 /**
  * @return string
  */
 protected function renderRelatedModelRelationHiddenInputContent()
 {
     $hiddenInputName = Element::resolveInputNamePrefixIntoString(array_merge($this->inputPrefixData, array('relatedModelRelation')));
     $hiddenInputId = Element::resolveInputIdPrefixIntoString(array_merge($this->inputPrefixData, array('relatedModelRelation')));
     $idInputHtmlOptions = array('id' => $hiddenInputId);
     return ZurmoHtml::hiddenField($hiddenInputName, $this->model->relatedModelRelation, $idInputHtmlOptions);
 }
 /**
  * @return A|string
  */
 protected function renderTypeContent()
 {
     $typeValuesAndLabels = $this->model->getTypeValuesAndLabels($this->isCreatingNewModel(), $this->isAttributeRequired);
     if (count($typeValuesAndLabels) > 1) {
         $params = array('inputPrefix' => $this->inputPrefixData, 'typeValuesAndLabels' => $typeValuesAndLabels);
         $typeElement = new WorkflowActionAttributeTypeStaticDropDownElement($this->model, 'type', $this->form, $params);
         $typeElement->editableTemplate = '{content}{error}';
         return $typeElement->render();
     } else {
         $label = reset($typeValuesAndLabels);
         $name = Element::resolveInputNamePrefixIntoString($this->inputPrefixData) . '[type]';
         $id = Element::resolveInputIdPrefixIntoString($this->inputPrefixData) . 'type';
         $htmlOptions = array('id' => $id);
         $content = ZurmoHtml::tag('span', array(), $label);
         $content .= ZurmoHtml::hiddenField($name, key($typeValuesAndLabels), $htmlOptions);
         return $content;
     }
 }
 protected function renderTypeContent()
 {
     $name = Element::resolveInputNamePrefixIntoString($this->inputPrefixData) . '[type]';
     $id = Element::resolveInputIdPrefixIntoString($this->inputPrefixData) . 'type';
     $htmlOptions = array('id' => $id);
     return ZurmoHtml::hiddenField($name, $this->emailMessageRecipientType, $htmlOptions);
 }