Skip to content

Commit

Permalink
Adding type properties to each class
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Dragoonis committed Jun 13, 2014
1 parent cd9b224 commit 7a082f7
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Element/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class Checkbox extends BaseElement
{

protected $type = 'checkbox';

/**
* Render the element
*
Expand Down
4 changes: 4 additions & 0 deletions src/Element/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ function __construct(array $options = array())
$this->setOptions($options);
$this->setAttributes($options);
$this->attributes = $options;

if(isset($options['name'])) {
$this->setName($options['name']);
}
}


Expand Down
2 changes: 2 additions & 0 deletions src/Element/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class Label extends BaseElement
{

protected $type = 'label';

/**
* Render the element
*
Expand Down
2 changes: 2 additions & 0 deletions src/Element/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class Password extends BaseElement
{

protected $type = 'password';

/**
* Render the element
*
Expand Down
2 changes: 2 additions & 0 deletions src/Element/Radio.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class Radio extends BaseElement
{

protected $type = 'radio';

/**
* Render the element
*
Expand Down
6 changes: 4 additions & 2 deletions src/Element/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class Select extends BaseElement
const optionsFormat = '<option %svalue="%s">%s</option>';
const selectFormat = '<select %s>%s</select>';

protected $values;
protected $type = 'select';

protected $values = array();

/**
* Dropdown Options
Expand Down Expand Up @@ -65,7 +67,7 @@ public function getValues()
function buildOptions()
{
$html = '';
foreach ($this->options as $key => $val) {
foreach ($this->values as $key => $val) {
$selected = '';
if ($this->selected !== null && $this->selected == $val) {
$selected = 'selected="selected" ';
Expand Down
3 changes: 3 additions & 0 deletions src/Element/Submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

class Submit extends BaseElement
{

protected $type = 'submit';

/**
* Render the element
*
Expand Down
2 changes: 2 additions & 0 deletions src/Element/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class Text extends BaseElement
{

protected $type = 'text';

/**
* Render the element
*
Expand Down
2 changes: 2 additions & 0 deletions src/Element/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class Textarea extends BaseElement
{

protected $type = 'textarea';

/**
* The textarea value
*
Expand Down
6 changes: 2 additions & 4 deletions src/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class Form
protected $elements = array();

protected $elementTypes = array(
'text', 'textarea', 'password', 'submit',
'checkbox', 'radio', 'hidden', 'select', 'dropdown'
'form', 'text', 'textarea', 'password', 'submit', 'label', 'checkbox', 'radio', 'hidden', 'select', 'dropdown'
);

/**
Expand All @@ -43,7 +42,7 @@ function __construct(array $options = array())
*/
public function create($action = '', $method = '', array $options = array())
{
return $this->add('form', '', array('method' => $method, 'action' => $action) + $options);
return $this->add('form', 'form', array('method' => $method, 'action' => $action) + $options);
}

/**
Expand All @@ -60,7 +59,6 @@ public function text($name, array $options = array())

public function label($label, $name = null, array $options = array())
{
throw new \Exception('To be implemented');
$name = 'label_for_' . $name;
return $this->add('label', $name, array('value' => $label) + $options);
}
Expand Down

0 comments on commit 7a082f7

Please sign in to comment.