You are here

public function RulesFormsAttributeWrapper::set in Rules Forms Support 7.2

Overrides EntityMetadataWrapper::set() to handle special circumstances.

Overrides EntityMetadataWrapper::set

File

includes/rules_forms.wrapper.inc, line 270
Manages and Process Form structure.

Class

RulesFormsAttributeWrapper
Wrapper class for form element attributes.

Code

public function set($value) {

  // The #options attribute is identified in property info as 'text' property
  // in order to provide the proper interface. However, that text is converted
  // to an array, so if this is an #options attribute we check to ensure that
  // we're either receiving text or an array.
  if ($this->info['name'] == '#options') {
    if (!is_string($value) && !is_array($value)) {
      throw new EntityMetadataWrapperException('Invalid data value given. Be sure it matches the required data type and format.');
    }
  }
  elseif (!$this
    ->validate($value)) {
    throw new EntityMetadataWrapperException('Invalid data value given. Be sure it matches the required data type and format.');
  }
  $this
    ->clear();
  $this->data = $value;
  $this
    ->updateParent($value);
  return $this;
}