Example #1
0
 public function ButtonClick2($strFormId, $strControlId, $strParameter)
 {
     $this->modal2->HideDialogBox();
     Bs\Modal::Alert("Button '" . $strParameter . "' was clicked");
 }
Example #2
0
 /**
  * Create a message dialog. Automatically adds an OK button that closes the dialog. To detect the close,
  * add an action on the Modal_HiddenEvent. To change the message, use the return value and set ->Text.
  * To detect a button click, add a QDialog_ButtonEvent.
  *
  * If you specify no buttons, a close box in the corner will be created that will just close the dialog. If you
  * specify just a string in $mixButtons, or just one string in the button array, one button will be shown that will just close the message.
  *
  * If you specify more than one button, the first button will be the default button (the one pressed if the user presses the return key). In
  * this case, you will need to detect the button by adding a QDialog_ButtonEvent. You will also be responsible for calling "Close()" on
  * the dialog after detecting a button.
  *
  * @param string $strMessage		// The message
  * @param string|string[]|null $strButtons
  * @param string|null $strControlId
  * @return Modal
  */
 public static function Alert($strMessage, $strButtons = null, $strControlId = null)
 {
     global $_FORM;
     $objForm = $_FORM;
     $dlg = new Modal($objForm, $strControlId);
     //$dlg->MarkAsModified(); // Make sure it gets drawn.
     $dlg->Text = $strMessage;
     $dlg->AddAction(new Modal_HiddenEvent(), new \QAjaxControlAction($dlg, 'Alert_Close'));
     if ($strButtons) {
         $dlg->blnHasCloseButton = false;
         if (is_string($strButtons)) {
             $dlg->AddCloseButton($strButtons);
         } elseif (count($strButtons) == 1) {
             $dlg->AddCloseButton($strButtons[0]);
         } else {
             $strButton = array_shift($strButtons);
             $dlg->AddButton($strButton, null, false, true);
             // primary button
             foreach ($strButtons as $strButton) {
                 $dlg->AddButton($strButton);
             }
         }
     } else {
         $dlg->blnHasCloseButton = true;
     }
     $dlg->ShowDialogBox();
     return $dlg;
 }