示例#1
0
/**
 * Get JSON attributes
 * @package Foundation\form
 */
function getAttributes(\Foundation\HTMLElement $object)
{
    $attributes = array();
    foreach ($object->getAttributes() as $memberName => $htmlName) {
        $method = 'get' . ucfirst($memberName);
        if (!method_exists($object, $method)) {
            throw new \Foundation\Exception("Unable to access {$memberName} using {$method} on " . get_class($f));
        }
        $value = $object->{$method}();
        if (!is_null($value)) {
            $attributes[] = array('name' => $htmlName, 'value' => $value);
        }
    }
    return $attributes;
}
示例#2
0
 /**
  * Constructor
  * @param \Foundation\Form $form the form that contains this field
  */
 public function __construct(\Foundation\Form $form)
 {
     parent::__construct();
     $this->addClass('field');
     $this->elements = array();
     $this->form = $form;
 }
示例#3
0
 public function __construct()
 {
     parent::__construct();
     $this->attributes['disabled'] = 'disabled';
     $this->attributes['value'] = 'value';
     $this->attributes['metadataString'] = 'data-metadata';
     $this->clearMetadata();
 }
示例#4
0
 /**
  * Constructor
  * @param \Foundation\Form\Field $field
  */
 public function __construct(\Foundation\Form\Field $field)
 {
     $this->field = $field;
     parent::__construct();
     $this->messages = array();
     $this->attributes['name'] = 'name';
     $this->attributes['accesskey'] = 'accesskey';
     $this->attributes['tabindex'] = 'tabindex';
     $this->validators = array();
     $this->filters = array();
     $this->addClass('field');
     //add the Element class without its namespace
     $class = \explode('\\', \get_class($this));
     $this->addClass($class[count($class) - 1]);
 }
示例#5
0
 /**
  * Construct
  */
 public function __construct()
 {
     parent::__construct();
     $this->links = array();
 }
示例#6
0
 /**
  * Add current to classes if we are current
  * @see Foundation.HTMLElement::getClass()
  */
 public function getClass()
 {
     $class = parent::getClass();
     if ($this->current) {
         $class = $class . ' current';
     }
     return $class;
 }