/** * {@inheritdoc} */ public function setValue($value, $data = null) { if (is_array($value) && isset($value['Geometry'])) { $this->geometryField->setValue($value['Geometry']); } elseif (is_string($value)) { $this->geometryField->setValue($value); } return $this; }
public function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldPageID->setValue($val['PageID']); $this->fieldCustomURL->setValue($val['CustomURL']); } elseif ($val instanceof LinkField) { $this->fieldPageID->setValue($val->getPageID()); $this->fieldCustomURL->setValue($val->getCustomURL()); } }
public function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldLatitude->setValue($val['Latitude']); $this->fieldLongditude->setValue($val['Longditude']); $this->fieldPositionSet->setValue($val['PositionSet']); } elseif ($val instanceof Location) { $this->fieldLatitude->setValue($val->getLatitude()); $this->fieldLongditude->setValue($val->getLongditude()); } }
public function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldPageID->setValue($val['PageID']); $this->fieldCustomURL->setValue($val['CustomURL']); $this->fieldTitle->setValue($val['Title']); $this->fieldLinkmode->setValue($val['Linkmode']); } elseif ($val instanceof NamedLinkField) { $this->fieldPageID->setValue($val->getPageID()); $this->fieldCustomURL->setValue($val->getCustomURL()); $this->fieldTitle->setValue($val->getTitle()); $this->fieldLinkmode->setValue($val->getLinkmode()); } }
/** * Sets the value of the field. * * @param string $value The value of the field * * @throws \InvalidArgumentException When value type provided is not correct */ public function setValue($value) { if ('checkbox' == $this->type && false === $value) { // uncheck $this->value = null; } elseif ('checkbox' == $this->type && true === $value) { // check $this->value = $this->options[0]; } else { if (is_array($value)) { if (!$this->multiple) { throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name)); } foreach ($value as $v) { if (!in_array($v, $this->options)) { throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->options))); } } } elseif (!in_array($value, $this->options)) { throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->options))); } if ($this->multiple && !is_array($value)) { $value = array($value); } if (is_array($value)) { $this->value = $value; } else { parent::setValue($value); } } }
public function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldType->setValue($val['Type']); $this->internalField->setValue($val['Internal']); $this->externalField->setValue($val['External']); $this->emailField->setValue($val['Email']); $this->fileField->setValue($val['File']); $this->anchorField->setValue($val['Anchor']); $this->targetBlankField->setValue(isset($val['TargetBlank']) ? $val['TargetBlank'] : false); $this->extraField->setValue($val['Extra']); $this->dataObjectField->setValue($val['DataObject']); } elseif ($val instanceof WTLink) { $this->fieldType->setValue($val->getType()); $this->internalField->setValue($val->getInternal()); $this->externalField->setValue($val->getExternal()); $this->emailField->setValue($val->getEmail()); $this->fileField->setValue($val->getFile()); $this->anchorField->setValue($val->getAnchor()); $this->targetBlankField->setValue($val->getTargetBlank()); $this->extraField->setValue($val->getExtra()); $this->dataObjectField->setValue($val->getDataObject()); } return $this; }
/** * define input values * * @param $values * * @since 1.0.0 */ public function setValue($values) { if (is_string($values)) { $values = explode(",", $values); } parent::setValue($values); }
/** * {@inheritdoc} */ public function setValue($record) { $this->latField->setValue($record['Latitude']); $this->lngField->setValue($record['Longitude']); $this->zoomField->setValue($record['Zoom']); return $this; }
/** * @param array|object $value */ public function setValue($value) { if (is_object($value)) { $value = $value->map('ID', 'Quantity'); } parent::setValue($value); }
/** * Value is sometimes an array, and sometimes a single value, so we need to handle both cases */ function setValue($value, $data = null) { if (is_array($data) && array_key_exists($this->getIsNullId(), $data) && $data[$this->getIsNullId()]) { $value = null; } $this->valueField->setValue($value); parent::setValue($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); }
/** * Do we do anything with data??? */ function setValue($data) { if ($this->buyable) { $value = $this->buyable->FullName ? $this->buyable->FullName : $this->buyable->getTitle(); //to TEST!!! $this->fieldSelectedBuyable->setValue("Once you have selected a new value, it will appear here..."); } }
function setValue($data) { if ($this->buyable) { $value = $this->buyable->FullName ? $this->buyable->FullName : $this->buyable->getTitle(); //to TEST!!! $this->fieldSelectedBuyable->setValue($value); } }
public function setValue($value) { if ($value instanceof EmbeddedObject) { $this->object = $value; parent::setValue($value->toMap()); } parent::setValue($value); }
function setValue($value) { if (!is_array($value)) { $this->valueArray = explode(',', $value); } else { $this->valueArray = $value; } return parent::setValue($value); }
/** * @param array $arr * @return $this */ public function setAllowedCurrencies($arr) { $this->allowedCurrencies = $arr; // @todo Has to be done twice in case allowed currencies changed since construction $oldVal = $this->fieldCurrency->dataValue(); $this->fieldCurrency = $this->buildCurrencyField(); $this->fieldCurrency->setValue($oldVal); return $this; }
/** * Transform a given form field into a composite field, where the translation is editable and the original value * is added as a read-only field. * @param FormField $field * @return CompositeField */ public function transformFormField(FormField $field) { $newfield = $field->performReadOnlyTransformation(); $fieldname = $field->getName(); if ($this->original->isLocalizedField($fieldname)) { $field->setName($this->original->getLocalizedFieldName($fieldname)); $field->setValue($this->original->getLocalizedValue($fieldname)); } return $this->baseTransform($newfield, $field, $fieldname); }
/** * Value is sometimes an array, and sometimes a single value, so we need to handle both cases * * @param mixed $value * @param null|array $data * * @return $this */ public function setValue($value, $data = null) { $id = $this->getIsNullId(); if (is_array($data) && array_key_exists($id, $data) && $data[$id]) { $value = null; } $this->valueField->setValue($value); parent::setValue($value); return $this; }
public function setValue($value, $obj = null) { // If we're not passed a value directly, we can look for it in a relation method on the object passed as a // second arg if (!$value && $obj && $obj instanceof DataObject && $obj->hasMethod($this->name)) { $funcName = $this->name; $value = $obj->{$funcName}()->getIDList(); } parent::setValue($value, $obj); return $this; }
public function getFormat() { $fields = AddressFormat::getOrderedAddressFields($this->country->id, true, true); $required = array_flip(AddressFormat::getFieldsRequired()); $format = ['id_address' => (new FormField())->setName('id_address')->setType('hidden'), 'id_customer' => (new FormField())->setName('id_customer')->setType('hidden'), 'back' => (new FormField())->setName('back')->setType('hidden'), 'token' => (new FormField())->setName('token')->setType('hidden'), 'alias' => (new FormField())->setName('alias')->setLabel($this->getFieldLabel('alias'))]; foreach ($fields as $field) { $formField = new FormField(); $formField->setName($field); $fieldParts = explode(':', $field, 2); if (count($fieldParts) === 1) { if ($field === 'postcode') { if ($this->country->need_zip_code) { $formField->setRequired(true); } } } elseif (count($fieldParts) === 2) { list($entity, $entityField) = $fieldParts; // Fields specified using the Entity:field // notation are actually references to other // entities, so they should be displayed as a select $formField->setType('select'); // Also, what we really want is the id of the linked entity $formField->setName('id_' . strtolower($entity)); if ($entity === 'Country') { $formField->setType('countrySelect'); $formField->setValue($this->country->id); foreach ($this->availableCountries as $country) { $formField->addAvailableValue($country['id_country'], $country[$entityField]); } } elseif ($entity === 'State') { if ($this->country->contains_states) { $states = State::getStatesByIdCountry($this->country->id); foreach ($states as $state) { $formField->addAvailableValue($state['id_state'], $state[$entityField]); } $formField->setRequired(true); } } } $formField->setLabel($this->getFieldLabel($field)); if (!$formField->isRequired()) { // Only trust the $required array for fields // that are not marked as required. // $required doesn't have all the info, and fields // may be required for other reasons than what // AddressFormat::getFieldsRequired() says. $formField->setRequired(array_key_exists($field, $required)); } $format[$formField->getName()] = $formField; } return $this->addConstraints($this->addMaxLength($format)); }
function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldAddress->setValue($val['Address']); $this->fieldLatitude->setValue($val['Latitude']); $this->fieldLongditude->setValue($val['Longditude']); } elseif ($val instanceof GeoLocation) { $this->fieldAddress->setValue($val->getAddress()); $this->fieldLatitude->setValue($val->getLatitude()); $this->fieldLongditude->setValue($val->getLongditude()); } }
/** * Sets the value of the field and also of the child fields. * @param array $value Submitted form data. * @param DataObject $record The dataobject containing the record data. * @return UploadField self reference. */ public function setValue($value, $record = null) { // Check if there is data for this object in the record, there is after the // form is submitted but normally not when the page is displayed for the first time. if (isset($record[$this->name])) { // Set the values for the lat and long fields to the values from the records // we need to do this otherwise the come saving time they will only have the default values. $this->latField->setValue($record[$this->name]['Latitude']); $this->lngField->setValue($record[$this->name]['Longitude']); $this->zoomField->setValue($record[$this->name]['Zoom']); } // Call parent to do the normal things including returning self reference. return parent::setValue($value, $record); }
function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldType->setValue($val['Type']); $this->internalField->setValue($val['Internal']); $this->externalField->setValue($val['External']); $this->emailField->setValue($val['Email']); $this->fileField->setValue($val['File']); $this->targetBlankField->setValue(isset($val['TargetBlank']) ? $val['TargetBlank'] : false); } elseif ($val instanceof WTLink) { $this->fieldType->setValue($val->getType()); $this->internalField->setValue($val->getInternal()); $this->externalField->setValue($val->getExternal()); $this->emailField->setValue($val->getEmail()); $this->fileField->setValue($val->getFile()); $this->targetBlankField->setValue($val->getTargetBlank()); } // @todo Format numbers according to current locale, incl. // decimal and thousands signs, while respecting the stored // precision in the database without truncating it during display // and subsequent save operations return $this; }
public function setValue($val) { $this->value = $val; if (is_array($val)) { $this->fieldPostcode->setValue($val['Postcode']); $this->fieldCountry->setValue($val['Country']); $this->fieldLatitude->setValue($val['Latitude']); $this->fieldLongditude->setValue($val['Longditude']); } elseif ($val instanceof PostCodeLocation) { $this->fieldPostcode->setValue($val->getPostcode()); $this->fieldCountry->setValue($val->getCountry()); $this->fieldLatitude->setValue($val->getLatitude()); $this->fieldLongditude->setValue($val->getLongditude()); } }
/** * {@inheritdoc} */ public function setValue($v) { if (is_array($v) && isset($v['_RawValue'], $v['_RecordID'])) { $this->getRecordIDField()->setValue($v['_RecordID']); $this->getRawField()->setValue($v['_RawValue']); } elseif (is_numeric($v)) { $this->getRecordIDField()->setValue($v); $record = $this->getRecord(); if ($record) { $this->getRawField()->setValue($record->{$this->config['displayKey']}); } } else { $this->getRawField()->setValue($v); } parent::setValue($v); return $this; }
public function setValue($v) { if (is_array($v)) { // we've been set directly via the post - lets prune any empty values foreach ($v as $key => $val) { if (!strlen($val)) { unset($v[$key]); } } } if ($v instanceof MultiValueField) { $v = $v->getValues(); } if (!is_array($v)) { $v = array(); } parent::setValue($v); }
public function setValue($value, $record = null) { if (empty($value) && $record) { if ($record instanceof DataObject && $record->hasMethod($this->getName())) { $data = $record->{$this->getName()}(); if ($data && $data->exists()) { $this->imageRecord = $data; } } } return parent::setValue($value, $record); }
/** * Sets path to the file as string for simulating HTTP request. * * @param string $path The path to the file */ public function setFilePath($path) { parent::setValue($path); }
/** * Transform a translatable field to show the field value from the default language * DataObject below the translated field. * * This is a fallback function which handles field types that aren't transformed by * $this->transform{FieldType} functions. * * @param FormField $nonEditableField The readonly field to contain the original value * @param FormField $originalField The original editable field containing the translated value * @return \CompositeField The transformed field */ protected function baseTransform($nonEditableField, $originalField) { $fieldname = $originalField->getName(); $nonEditableField_holder = new CompositeField($nonEditableField); $nonEditableField_holder->setName($fieldname . '_holder'); $nonEditableField_holder->addExtraClass('originallang_holder'); $nonEditableField->setValue($this->original->{$fieldname}); $nonEditableField->setName($fieldname . '_original'); $nonEditableField->addExtraClass('originallang'); $nonEditableField->setTitle(_t('Translatable_Transform.OriginalFieldLabel', 'Original {title}', 'Label for the original value of the translatable field.', array('title' => $originalField->Title()))); $nonEditableField_holder->insertBefore($originalField, $fieldname . '_original'); return $nonEditableField_holder; }
public function setValue($value) { // Allow set raw json as value if ($value && is_string($value) && strpos($value, '[') === 0) { $value = json_decode($value); } parent::setValue($value); }