Exemplo n.º 1
0
Arquivo: edit.php Projeto: alcf/chms
 protected function Form_Create()
 {
     $this->mctAttribute = AttributeMetaControl::Create($this, QApplication::PathInfo(0));
     $this->strPageTitle = 'Administration - ' . ($this->mctAttribute->EditMode ? 'Edit' : 'Create New') . ' Attribute';
     $this->txtName = $this->mctAttribute->txtName_Create();
     $this->txtName->Required = true;
     $this->lstAttributeDataType = $this->mctAttribute->lstAttributeDataType_Create();
     if ($this->mctAttribute->EditMode) {
         $this->lstAttributeDataType->Enabled = false;
     }
     $this->btnSave = new QButton($this);
     $this->btnSave->Text = $this->mctAttribute->EditMode ? 'Update' : 'Create';
     $this->btnSave->CssClass = 'primary';
     $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
     $this->btnSave->CausesValidation = true;
     $this->btnCancel = new QLinkButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnCancel->CssClass = 'cancel';
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
     switch ($this->mctAttribute->Attribute->AttributeDataTypeId) {
         case AttributeDataType::ImmutableMultipleDropdown:
         case AttributeDataType::ImmutableSingleDropdown:
         case AttributeDataType::MutableMultipleDropdown:
         case AttributeDataType::MutableSingleDropdown:
             $this->pnlAttributeOptions = new QPanel($this);
             $this->pnlAttributeOptions->AutoRenderChildren = true;
             $this->btnAddMore = new QLinkButton($this);
             $this->btnAddMore->Name = ' ';
             $this->btnAddMore->Text = 'Add More Dropbox Values';
             $this->btnAddMore->ForeColor = '#999';
             $this->btnAddMore->AddAction(new QClickEvent(), new QAjaxAction('btnAddMore_Click'));
             $this->btnAddMore->AddAction(new QClickEvent(), new QTerminateAction());
             break;
     }
     if ($this->mctAttribute->EditMode) {
         $this->btnDelete = new QLinkButton($this);
         $this->btnDelete->Text = 'Delete';
         $this->btnDelete->CssClass = 'delete';
         $intCount = $this->mctAttribute->Attribute->CountAttributeValues();
         $strConfirmText = sprintf('Are you SURE you want to permanently DELETE this Attribute?  There are %s individual%s that have a value for this attribute which would be removed.', $intCount, $intCount == 1 ? '' : 's');
         $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction($strConfirmText));
         $this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click'));
         $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction());
         if ($this->pnlAttributeOptions) {
             foreach ($this->mctAttribute->Attribute->GetAttributeOptionArray(QQ::OrderBy(QQN::AttributeOption()->Name)) as $objAttributeOption) {
                 $this->pnlAttributeOptions_AddOption($objAttributeOption);
             }
         }
     }
     if ($this->pnlAttributeOptions) {
         $this->pnlAttributeOptions_AddOption(null);
         $this->pnlAttributeOptions_AddOption(null);
     }
 }
Exemplo n.º 2
0
 /**
  * Static Helper Method to Create using QueryString arguments
  *
  * @param mixed $objParentObject QForm or QPanel which will be using this AttributeMetaControl
  * @param QMetaControlCreateType $intCreateType rules governing Attribute object creation - defaults to CreateOrEdit
  * @return AttributeMetaControl
  */
 public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     $intId = QApplication::QueryString('intId');
     return AttributeMetaControl::Create($objParentObject, $intId, $intCreateType);
 }