public function ReferencedPage()
 {
     if ($this->FormPage()) {
         $result = new UserDefinedForm_Controller($this->FormPage());
         $result->init();
         return $result;
     }
 }
 public function Form()
 {
     if ($this->FormPage()) {
         $result = new UserDefinedForm_Controller($this->FormPage());
         $result->init();
         return $result->Form();
     }
     return false;
 }
 public function ElementForm()
 {
     if ($this->Form()->exists()) {
         $controller = new UserDefinedForm_Controller($this->Form());
         $current = Controller::curr();
         if ($current && $current->getAction() == 'finished') {
             return $controller->renderWith('ReceivedFormSubmission');
         }
         $form = $controller->Form();
         return $form;
     }
 }
 public function Layout()
 {
     $page = Director::get_current_page();
     $member = Member::currentUser();
     $access = Permission::checkMember($member, 'CMS_ACCESS');
     $sectionType = get_called_class();
     if ($this->Public || $access) {
         // Added UserDefinedForm to section
         if (in_array('UserDefinedForm', ClassInfo::ancestry($page->ClassName))) {
             $result = new UserDefinedForm_Controller($page);
             $result->init();
             $page->Form = $result->Form();
         }
         return $page->renderWith($this->Render());
     }
 }
Exemple #5
0
 /**
  * User form
  *
  * @return  UserForm
  */
 public function Form()
 {
     $form = parent::Form();
     $form->addExtraClass('forms');
     $fields = $form->Fields();
     $actions = $form->Actions();
     foreach ($actions as $action) {
         $action->useButtonTag = true;
         $action->addExtraClass('hvr-bounce-to-right');
     }
     return $form;
 }
 /**
  * Make sure all omnipay fields are required
  *
  * @todo: make this more flexible
  *
  * @return RequiredFields
  */
 public function getRequiredFields()
 {
     $required = parent::getRequiredFields();
     $gateway = $this->data()->PaymentGateway;
     $fieldgroups = $this->getPaymentFieldsGroupArray();
     $factory = new GatewayFieldsFactory($gateway, $fieldgroups);
     $fields = $factory->getFields();
     foreach ($fields as $field) {
         if (!$field->hasMethod('getName')) {
             continue;
         }
         $fieldname = $field->getName();
         if ($fieldname == "billingAddress2") {
             continue;
         }
         $required->addRequiredField($fieldname);
     }
     $paymentfieldname = $this->PaymentAmountField()->Name;
     $required->addRequiredField($paymentfieldname);
     return $required;
 }
 public function Form()
 {
     $form = parent::Form();
     $form = FormFieldExplanationExtension::add_explanations($form, $this->dataRecord);
     return $form;
 }
 /**
  * Returns an instance of Form Object.
  *
  * @return Form
  */
 function Form()
 {
     $form = parent::Form();
     /*@var $form Form */
     if ($this->AllNewsletters) {
         $newsletterList = DataObject::get('NewsletterType');
     } else {
         $newsletterList = $this->Newsletters();
     }
     $newsletters = array();
     // get the newsletter types to display on the form
     foreach ($newsletterList as $newsletter) {
         $newsletters[$newsletter->ID] = $newsletter->Title;
     }
     $form->Fields()->push(new CheckboxSetField('Newsletters', 'Subscribe to lists', $newsletters));
     $validator = $form->getValidator();
     $validator->addRequiredField('Newsletters');
     $form->setValidator($validator);
     return $form;
 }
 public function Form()
 {
     $form = parent::Form();
     if (!$form) {
         return;
     }
     if ($this->ShowButtonsOnTop) {
         $form->ShowButtonsOnTop = true;
     }
     $form->setTemplate('EditableUserDefinedFormControl');
     // now add an action for "Save"
     $fields = $form->Fields();
     // first, lets add any custom Note text that is needed
     foreach ($this->Fields() as $editableField) {
         if ($editableField instanceof EditableFileField) {
             $fields->removeByName($editableField->Name);
             continue;
         }
         $formField = $fields->fieldByName($editableField->Name);
         if ($formField && $editableField->getSetting('Note')) {
             $title = $formField->Title() . '<span class="userformFieldNote">' . Convert::raw2xml($editableField->getSetting('Note')) . '</span>';
             $formField->setTitle($title);
         }
     }
     // lets see if there's a submission that we should be loading into the form
     if ($this->submission && $this->submission->ID) {
         $this->submission->exposeDataFields();
         $form->loadDataFrom($this->submission);
         $fields->push(new HiddenField('ResumeID', '', $this->submission->ID));
         $workflowState = $this->submission->getWorkflowState();
         if ($workflowState !== false) {
             $form->addExtraClass("workflow-review");
             if ($workflowState == 'Readonly') {
                 $fields->unshift(LiteralField::create('workflow_warning', '<p class="message warning">Currently under review</p>'));
                 $this->readonly = true;
             } else {
                 $fields->unshift(LiteralField::create('workflow_warning', '<p class="message warning">Review via ' . Convert::raw2xml($workflowState) . ' </p>'));
             }
         }
     }
     if ($this->readonly) {
         $form->makeReadonly();
     }
     $actions = $form->Actions();
     if (!$this->ShowSubmitButton) {
         $actions->removeByName('action_process');
     } else {
         if (strlen($this->SubmitWarning)) {
             $submitName = $actions->fieldByName('action_process');
             $submitName->setAttribute('data-submitwarning', Convert::raw2att($this->SubmitWarning));
             $submitName->addExtraClass('submitwarning');
         }
     }
     if (!$this->readonly) {
         if (Member::currentUserID()) {
             $actions->push($action = new FormAction('storesubmission', 'Save'));
             $action->setAttribute('formnovalidate', 'formnovalidate');
             // $actions->push(new FormAction('cancelsubmission', 'Cancel', null, null, 'cancel'));
             if ($this->ShowPreviewButton) {
                 $actions->push($action = new FormAction('previewsubmission', 'Preview'));
                 $action->setAttribute('formnovalidate', 'formnovalidate');
                 $actions->push($action = new FormAction('previewpdfsubmission', 'PDF / Print'));
                 $action->setAttribute('formnovalidate', 'formnovalidate');
             }
             if ($this->submission && $this->ShowDeleteButton) {
                 $actions->push($action = new FormAction('cancelsubmission', 'Delete'));
                 $action->setAttribute('formnovalidate', 'formnovalidate');
             }
         }
     } else {
         $form->setActions(ArrayList::create());
     }
     if ($this->submission && $this->readonly) {
         $actions->push(new LiteralField("PrintLink", '<a class="editableFormPDFLink" href="' . $this->submission->PDFLink() . '">Download PDF</a>'));
     }
     // finally - we want to check if this request is trying to do an action that doesn't care about validation.
     // IF we are, then we want to clear the validation for this form
     if (!isset($_REQUEST['action_process'])) {
         $form->unsetValidator();
     }
     return $form;
 }
 public function init()
 {
     parent::init();
 }
 public function init()
 {
     parent::init();
     Requirements::css(CONSULTATION_MODULE_DIR . '/css/consultations.css');
 }