/** * SaveInto checks if set-methods are available and use them instead of setting the values directly. saveInto * initiates a new LinkField class object to pass through the values to the setter method. */ public function saveInto(DataObjectInterface $dataObject) { $fieldName = $this->name; if ($dataObject->hasMethod("set{$fieldName}")) { $dataObject->{$fieldName} = DBField::create('LinkField', array("PageID" => $this->fieldPageID->Value(), "CustomURL" => $this->fieldCustomURL->Value())); } else { $dataObject->{$fieldName}->setPageID($this->fieldPageID->Value()); $dataObject->{$fieldName}->setCustomURL($this->fieldCustomURL->Value()); } }
/** * 30/06/2009 - Enhancement: * SaveInto checks if set-methods are available and use them * instead of setting the values in the money class directly. saveInto * initiates a new Money class object to pass through the values to the setter * method. * */ function saveInto(DataObjectInterface $dataObject) { $fieldName = $this->name; if ($dataObject->hasMethod("set{$fieldName}")) { $dataObject->{$fieldName} = DBField::create_field('WTLink', array("Type" => $this->fieldType->Value(), "Internal" => $this->internalField->Value(), "External" => $this->externalField->Value(), "Email" => $this->emailField->Value(), "File" => $this->fileField->Value(), "TargetBlank" => $this->targetBlankField->Value())); } else { if (!empty($dataObject->{$fieldName})) { $dataObject->{$fieldName}->setType($this->fieldType->Value()); $dataObject->{$fieldName}->setInternal($this->internalField->Value()); $dataObject->{$fieldName}->setExternal($this->externalField->Value()); $dataObject->{$fieldName}->setEmail($this->emailField->Value()); $dataObject->{$fieldName}->setFile($this->fileField->Value()); $dataObject->{$fieldName}->setTargetBlank($this->targetBlankField->Value()); } } }
/** * @param array $arr */ function setAllowedCurrencies($arr) { $this->allowedCurrencies = $arr; // @todo Has to be done twice in case allowed currencies changed since construction $oldVal = $this->fieldCurrency->Value(); $this->fieldCurrency = $this->FieldCurrency($this->name); $this->fieldCurrency->setValue($oldVal); }
/** * 30/06/2009 - Enhancement: * SaveInto checks if set-methods are available and use them * instead of setting the values in the money class directly. saveInto * initiates a new Money class object to pass through the values to the setter * method. * * (see @link MoneyFieldTest_CustomSetter_Object for more information) */ public function saveInto(DataObjectInterface $dataObject) { $fieldName = $this->name; if ($dataObject->hasMethod("set{$fieldName}")) { $dataObject->{$fieldName} = DBField::create_field('Location', array("Latitude" => $this->fieldLatitude->Value(), "Longditude" => $this->fieldLongditude->Value())); } else { $dataObject->{$fieldName}->setLatitude($this->fieldLatitude->Value()); $dataObject->{$fieldName}->setLongditude($this->fieldLongditude->Value()); } }
/** * Create a new nullable field * @param $valueField * @return NullableField */ function __construct(FormField $valueField, $isNullLabel = null) { $this->valueField = $valueField; $this->isNullLabel = $isNullLabel; if (is_null($this->isNullLabel)) { // Set a default label if one is not provided. $this->isNullLabel = _t('NullableField.IsNullLabel', 'Is Null'); } parent::__construct($valueField->getName(), $valueField->Title(), $valueField->Value(), $valueField->getForm(), $valueField->RightTitle()); $this->readonly = $valueField->isReadonly(); }
/** * Create a new nullable field * * @param FormField $valueField * @param null|string $isNullLabel */ public function __construct(FormField $valueField, $isNullLabel = null) { $this->valueField = $valueField; if (isset($isNullLabel)) { $this->setIsNullLabel($isNullLabel); } else { $this->isNullLabel = _t('NullableField.IsNullLabel', 'Is Null'); } parent::__construct($valueField->getName(), $valueField->Title(), $valueField->Value()); $this->setForm($valueField->getForm()); $this->setRightTitle($valueField->RightTitle()); $this->setReadonly($valueField->isReadonly()); }
/** * SaveInto checks if set-methods are available and use them instead of setting the values directly. saveInto * initiates a new LinkField class object to pass through the values to the setter method. */ public function saveInto(DataObjectInterface $dataObject) { $fieldName = $this->name; if ($dataObject->hasMethod("set{$fieldName}")) { $dataObject->{$fieldName} = DBField::create('NamedLinkField', array("PageID" => $this->fieldPageID->Value(), "CustomURL" => $this->fieldCustomURL->Value(), "Title" => $this->fieldTitle->Value(), "Linkmode" => $this->fieldLinkmode->Value())); } else { if (!is_object($dataObject->{$fieldName})) { $dataObject->{$fieldName} = NamedLinkField::create(); } $dataObject->{$fieldName}->setPageID($this->fieldPageID->Value()); $dataObject->{$fieldName}->setCustomURL($this->fieldCustomURL->Value()); $dataObject->{$fieldName}->setTitle($this->fieldTitle->Value()); $dataObject->{$fieldName}->setLinkmode($this->fieldLinkmode->Value()); } }
protected function augmentMailChimpField(FormField $field, string $component, FlexiFormMailChimpClient $client) { switch ($component) { case 'MailChimpSendWelcome': $field->setTitle('Send Welcome Email'); $field->description = 'flag to control whether the Welcome Email is sent. Has no effect if double opt-in is enabled.'; break; case 'MailChimpDoubleOptIn': $field->setTitle('Require Double Opt-In'); $field->description = 'flag to control whether a double opt-in confirmation message is sent, defaults to true. Abusing this may cause your account to be suspended.'; break; case 'MailChimpEmailField': $field->setTitle('Subscription Field'); $field->description = 'Used as the subscriber email. Must be an Email Field or subclass.'; break; case 'MailChimpEmailType': // @TODO ought to let user select preference through a form field [ similar to interest groups? ] $field->setTitle('Email Preference'); $field->description = 'email type preference for subscribers (html or text - defaults to html)'; break; case 'MailChimpApiKey': if ($client->isApiKeyValid()) { $field->description = 'This API Key is Valid.'; } else { if ($client->getApiKey() == '') { $field->description = 'Your MailChimp API Key. Found under Account Extras > Your API Keys'; } else { $field->description = 'This API Key is not Valid.'; } } $field->setTitle('MailChimp API Key'); break; case 'MailChimpListID': if ($lists = $client->getLists(array('limit' => 100, 'sort_field' => 'web'))) { $value = $field->Value(); $source = array('' => 'Please Select a List'); $field = new DropdownField($field->getName()); $field->description = 'Subscribers will be added to this list. Lists are refreshed every 10 minutes.'; if ($lists['total'] > 0) { foreach ($lists['data'] as $list) { $source[$list['id']] = $list['name']; } } $field->setValue($value); $field->setSource($source); } else { $field = $field->performReadonlyTransformation(); if (!$client->isApiKeyValid()) { $field->setValue('Invalid API Key'); } else { $field->setValue('Error loading Lists from your Account'); } } $field->setTitle('MailChimp List ID'); break; } return $field; }