Example #1
0
 protected function _postBind()
 {
     parent::_postBind();
     $this->getElement('plainText')->setType(FormElement::TEXTAREA);
     $this->getElement('htmlContent')->setType(FormElement::TEXTAREA);
     $this->getElement('campaignId')->setType(FormElement::NONE);
 }
Example #2
0
 protected function _postBind()
 {
     if ($this->_mapper->id()) {
         $this->getElement("reference")->addAttribute("disabled", "disabled");
     }
     $this->getElement("signature")->setType(FormElement::TEXTAREA);
     $return = parent::_postBind();
     $this->getElement("submit")->addAttribute("data-loading-text", "Submitting Contact");
     return $return;
 }
 public function renderEdit($pid)
 {
     $processors = $this->_campaign->processors;
     $definedProcessors = $this->config('processors')->jsonSerialize();
     if (!isset($processors[$pid])) {
         return $this->renderNew();
     }
     $pData = $processors[$pid];
     $form = new DeferoForm('edit_processor');
     $form->addSelectElement('processorType', array_map('class_shortname', $definedProcessors));
     $form->getElement('processorType')->addAttribute('disabled');
     $processor = $this->config('processors')->getStr($pData->processorType);
     $processor = new $processor();
     // populate types
     $class = new \ReflectionClass($processor);
     foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) {
         $default = $p->getValue($processor);
         // get property type (enum)
         // use reflection to check for enumclass
         if ($t = DocBlockHelper::getBlock($processor, $p->getName(), 'enumclass')) {
             $form->addSelectElement($p->getName(), (new OptionBuilder(new $t()))->getOptions(), $default);
         } else {
             $form->addTextElement($p->getName(), $default);
         }
     }
     $form->addSubmitElement();
     $form->hydrate((array) $processor);
     $form->hydrate((array) $pData);
     if ($this->request()->postVariables()) {
         $form->hydrate($this->request()->postVariables());
         if ($form->isValid() && $form->csrfCheck()) {
             $processors[$pid] = $form->jsonSerialize();
             $this->_campaign->processors = $processors;
             $this->_campaign->saveChanges();
             return Redirect::to('/campaigns/' . $this->getInt('cid'));
         }
     }
     echo $form;
 }
Example #4
0
 protected function _postBind()
 {
     $this->getElement("active")->setLabelPosition(Form::LABEL_NONE);
     $this->getElement('dataSourceOptions')->setType(FormElement::NONE);
     $this->getElement('processors')->setType(FormElement::NONE);
     $this->getElement('availableLanguages')->setType(FormElement::NONE);
     $this->getElement('lastSent')->setType(FormElement::NONE);
     $this->getElement('sortOrder')->setType(FormElement::NONE);
     if ($this->_mapper->id()) {
         $this->getElement("reference")->addAttribute("disabled", "disabled");
     }
     $return = parent::_postBind();
     $this->getElement("submit")->addAttribute("data-loading-text", "Submitting Campaign");
     return $return;
 }
Example #5
0
 public function renderTest($id)
 {
     $campaign = new Campaign($id);
     $form = new DeferoForm('send_test_email');
     $form->addTextElement('email');
     foreach ($campaign->message()->findVariables() as $var) {
         $form->addTextElement($var);
     }
     $form->get('email')->setRequired(true);
     $form->addSubmitElement();
     if ($post = $this->request()->postVariables()) {
         $form->hydrate($post);
         if ($form->isValid() && $form->csrfCheck(true)) {
             try {
                 Defero::pushMessage($id, $form->jsonSerialize());
                 $msg = new TransportMessage("info", 'Test queued for user');
             } catch (\Exception $e) {
                 $msg = new TransportMessage("error", $e->getMessage());
             }
             return Redirect::to("/campaigns/{$id}")->with("msg", $msg);
         }
     }
     return new RenderGroup('<h1>Send a Test Campaign</h1>', $form);
 }