public function __construct()
 {
     $this->addComponent(new GridFieldButtonRow('before'));
     $this->addComponent(new GridFieldAddNewMultiClass('buttons-before-left'));
     $this->addComponent(new GridFieldAddExistingSearchButton('buttons-before-right'));
     $this->addComponent(new GridFieldToolbarHeader());
     $this->addComponent(new GridFieldTitleHeader());
     $this->addComponent(new GridFieldEditableColumns());
     $this->addComponent(new GridFieldEditButton());
     $this->addComponent(new GridFieldDeleteAction(true));
     $this->addComponent(new GridFieldDetailForm());
     // Validation
     // ///////////
     $component = $this->getComponentByType('GridFieldDetailForm');
     $component->setValidator(new RequiredFields(array('FieldName')));
     // Sort Order
     // ///////////
     $this->addComponent(new GridFieldOrderableRows('SortOrder'));
     // Inline Editing
     // ///////////////
     $component = $this->getComponentByType('GridFieldEditableColumns');
     $component->setDisplayFields(array('Label' => array('title' => 'Type', 'field' => 'ReadonlyField'), 'Name' => array('title' => 'Name', 'field' => 'TextField'), 'Prompt' => array('title' => 'Prompt', 'field' => 'TextField'), 'DefaultValue' => array('title' => 'Default Value', 'callback' => function ($record, $column_name, $grid) {
         return $record->hasMethod('getDefaultValueFormField') ? $record->getDefaultValueFormField('DefaultValue') : new TextField($column_name);
     }), 'Required' => array('title' => 'Required', 'field' => 'CheckboxField')));
     // CSS improvements
     // /////////////////
     FlexiFormUtil::include_requirements();
 }
 public function getFlexiFormObject($identifier = null)
 {
     // by default, we assume the flexi form is the controller's data record.
     // You may provide an identifier or override as neccessary.
     $flexi = $this->flexiform_object ?: $this->owner->data();
     if ($identifier && !($flexi = FlexiFormUtil::GetFlexiByIdentifier($identifier))) {
         throw new Exception("No Flexi with identifier `{$identifier}` found");
     }
     if (!$flexi->hasExtension('FlexiFormExtension')) {
         throw new Exception('Flexi Form not found. Try passing an Identifier, or setting.');
     }
     return $flexi;
 }
Esempio n. 3
0
 public function getLoginForm($aRow = null, $bReload = false)
 {
     if ($this->aLoginForm != null) {
         return $this->aLoginForm;
     }
     if (!empty($aRow["error"])) {
         FlexiPlatformHandler::getPlatformHandler()->addMessage($aRow["error"], "error");
     }
     $iSize = 25;
     $this->aLoginForm = $aForm = array("txtLogin" => array("#type" => "textfield", "#title" => flexiT("User-Id", "first"), "#weight" => 5, "#maxlength" => 100, "#required" => true, "#size" => $iSize, "#default_value" => ""), "txtPassword" => array("#type" => "password", "#title" => flexiT("Password", "first"), "#weight" => 7, "#maxlength" => 50, "#required" => true, "#size" => $iSize, "#default_value" => ""), "txtURL" => array("#type" => "hidden", "#default_value" => FlexiConfig::$sBaseURL), "bSubmit" => array("#type" => "submit", "#value" => flexiT("Login", "first"), "#weight" => 57));
     //fill in form value
     FlexiFormUtil::mergeFormWithData($aForm, $aRow);
     $aTheForm = array_merge($aForm, array("#type" => "form", "#upload" => false, "#method" => "post", "#action" => flexiURL("mod=FlexiLogin&method=login")));
     $aTheLoginForm = array("#type" => "div", "#title" => flexiUCFirstT("login form"), "form" => $aTheForm, "#attributes" => array("class" => "flexiphp_login_div"));
     //todo event for form before output
     $this->aLoginForm = $aTheLoginForm;
     return $this->aLoginForm;
 }
 public function onConfigUpdate(FlexiFormConfig $config, DataObject $flexi)
 {
     $fields = $flexi->FlexiFormFields();
     $requested_groups = (array) Controller::curr()->getRequest()->requestVar('FlexiFormMailChimpGroups');
     $current_groups = array();
     // remove non requested groups from field list
     foreach ($fields as $field) {
         if ($field->is_a('FlexiMailChimpInterestGroupField')) {
             if (in_array($field->InterestGroupID, $requested_groups)) {
                 $current_groups[] = $field->InterestGroupID;
             } else {
                 $fields->remove($field);
                 $field->delete();
             }
         }
     }
     // calculate groups that need to be added to field list
     $new_groups = array_diff($requested_groups, $current_groups);
     if (!empty($new_groups)) {
         $client = new FlexiFormMailChimpClient($flexi->FlexiFormSetting('MailChimpApiKey')->getValue());
         $list_id = $flexi->FlexiFormSetting('MailChimpListID')->getValue();
         $groups = $this->getInterestGroups($list_id, $client);
         foreach ($new_groups as $group_id) {
             if ($group = $groups->find('id', $group_id)) {
                 $options = array();
                 foreach ($group['groups'] as $option) {
                     // mailchimp subscribe API uses names vs. IDs...
                     //$options[$option['id']] = $option['name'];
                     $options[$option['name']] = $option['name'];
                 }
                 $field = FlexiFormUtil::CreateFlexiField('FlexiMailChimpInterestGroupField', array('Name' => $group['name'], 'InterestGroupID' => $group['id'], 'InterestGroupFormField' => $group['form_field'], 'Readonly' => true, 'Options' => $options));
                 $fields->add($field, array('Prompt' => $group['name']));
             }
         }
     }
     return parent::onConfigUpdate($config, $flexi);
 }
Esempio n. 5
0
 public function prepareForm(&$aForm, $asValues = null)
 {
     return FlexiFormUtil::mergeFormWithData($aForm, $asValues);
 }
 public function checkAccessAction($action)
 {
     return $action != 'httpSubmission' && FlexiFormUtil::GetFlexiByIdentifier($action) ? true : parent::checkAccessAction($action);
 }
 public function onAfterWrite()
 {
     $conf = $this->FlexiFormConf();
     // ensure valid config
     //////////////////////
     if (!$conf->exists()) {
         if ($name = $this->getFlexiFormDefaultHandlerName()) {
             if ($handler = FlexiFormHandler::get()->filter('HandlerName', $name)->first()) {
                 $conf->HandlerID = $handler->ID;
             }
         }
         $conf->FlexiFormID = $this->owner->ID;
         $conf->FlexiFormClass = $this->owner->class;
         $conf->write();
         $this->owner->FlexiFormConfigID = $conf->ID;
         $this->owner->write();
     }
     // initialize fields on new forms
     /////////////////////////////////
     if (!$this->FlexiFormConf('InitializedFields')) {
         $definitions = $this->getFlexiFormInitialFields();
         if (!empty($definitions)) {
             $fields = $this->owner->FlexiFormFields();
             foreach ($definitions as $definition) {
                 if (!is_array($definition) || !isset($definition['Name']) || !isset($definition['Type'])) {
                     throw new ValidationException('Initial Field Definitions must be an associative array, with at least Name and Type provided.');
                 }
                 // lookup field name, prioritizing Readonly fields
                 if (!($field = FlexiFormField::get()->sort('Readonly', 'DESC')->filter(array('FieldName' => $definition['Name'], 'ClassName' => $definition['Type']))->first())) {
                     $field = FlexiFormUtil::CreateFlexiField($definition['Type'], $definition);
                 }
                 $extraFields = array();
                 foreach (array_intersect_key($definition, $fields->getExtraFields()) as $property => $value) {
                     $extraFields[$property] = $value;
                 }
                 $fields->add($field, $extraFields);
             }
             $conf->InitializedFields = true;
             $conf->write();
         }
     }
     // seed Form Identifier
     ///////////////////////
     if (!$this->FlexiFormID()) {
         $conf = $this->FlexiFormConf();
         // @TODO perhaps base on title of extended object??
         $conf->FormIdentifier = "{$this->owner->class}_{$this->owner->ID}";
         $conf->write();
     }
     return parent::onAfterWrite();
 }
Esempio n. 8
0
 public function getFieldSafeTags(FlexiTableFieldObject $oField)
 {
     $aResultTag = array();
     $aAttribute = array();
     return FlexiFormUtil::getSafeTagsAttributes($oField->allowtag);
 }
 public function requireDefaultRecords()
 {
     foreach ($this->getRequiredHandlerDefinitions() as $definition) {
         FlexiFormUtil::AutoCreateFlexiHandler($this->ClassName, $definition);
     }
     return parent::requireDefaultRecords();
 }
 public static function AutoCreateFlexiHandler($className, $definition)
 {
     // Handler Names are Unique.
     $filter = array('HandlerName' => $definition['Name']);
     // only create handler it doesn't yet exist
     if (!FlexiFormHandler::get()->filter($filter)->first()) {
         if ($obj = FlexiFormUtil::CreateFlexiHandler($className, $definition)) {
             DB::alteration_message("flexiform - Created {$className} named `{$obj->HandlerName}`.", "created");
         }
     }
 }
Esempio n. 11
0
echo FlexiFormUtil::tinyMCEInitControl($aForm);
?>
    });
  tabs.setActiveTab(1);
  tabs.items.itemAt(1).setTitle("<span>Edit Setting</span>");
}
function cancelForm() {
  jQuery("#divProfileForm").html("Loading...");
  <?php 
echo FlexiFormUtil::tinyMCERemoveControl($aForm);
?>
  jQuery("#divProfileForm").load("<?php 
echo $this->url(null, "form", $vars["#module"], "", true);
?>
", function(response, status, xhr) {
    <?php 
echo FlexiFormUtil::tinyMCEInitControl($aForm);
?>
  });
  tabs.items.itemAt(1).setTitle("<span>New Setting</span>");
  tabs.setActiveTab(0);
}
</script>

	<? else: ?>
		No records found
	<? endif; ?>
		<? //var_dump($vars["aList"]) ?>
	</div>
</div>