Example #1
0
 /**
  * Create a field object for the EAV attribute with the supplied name.  You
  * should check to ensure the attribute exists prior to calling this method.
  *
  * @param string $name
  * @return \Dewdrop\Db\Eav\Field
  */
 public function instantiate($name)
 {
     $definition = $this->table->getEav();
     $metadata = $definition->getFieldMetadata($name);
     $attribute = $definition->getAttribute($name);
     $field = new Field($this->table, $name, $metadata);
     $field->setDefinition($definition);
     if ($attribute[$definition->getRequiredIndex()]) {
         $field->setRequired(true);
     }
     return $field;
 }