Example #1
0
 function __construct($name = null, $options = null, $selected = null, $multiple = false)
 {
     if ($name !== null) {
         $this->attributes['name'] = $name;
     }
     if ($selected !== null) {
         $this->selected = $selected;
     }
     if (!$this->selected) {
         // Try this request first
         if (\Forma\Helpers::input($this->attributes['name'])) {
             $this->selected = \Forma\Helpers::input($this->attributes['name']);
         }
         // Old input
         if (\Forma\Helpers::inputOld($this->attributes['name'])) {
             $this->selected = \Forma\Helpers::inputOld($this->attributes['name']);
         }
     }
     if ($multiple) {
         $this->attr('multiple', true);
     }
     if (is_array($options)) {
         $this->options($options);
     }
     // Add pre-renders for traits
     $this->preRenders[] = 'preRenderWithLabel';
     $this->preRenders[] = 'preRenderWrapLabel';
     // Add post-renders for traits
     $this->postRenders[] = 'postRenderWrapLabel';
 }
Example #2
0
 function __construct($text = null, $value = null, $selected = false)
 {
     if ($value !== null) {
         $this->attributes['value'] = $value;
     }
     if ($selected) {
         $this->attributes['selected'] = null;
     }
     $this->text = \Forma\Helpers::hasLang($text) ? \Forma\Helpers::lang($text) : $text;
 }
Example #3
0
 public function render()
 {
     $tagString = '';
     // Pre-Renders
     foreach ($this->preRenders as $func) {
         $tagString .= $this->{$func}();
     }
     $tagString .= "<" . $this->tagName;
     // Determine value??
     if ($this->hasValue and isset($this->attributes['name'])) {
         // Try this request first
         if (\Forma\Helpers::input($this->attributes['name'])) {
             $this->attributes['value'] = \Forma\Helpers::input($this->attributes['name']);
         }
         // Old input
         if (\Forma\Helpers::inputOld($this->attributes['name'])) {
             $this->attributes['value'] = \Forma\Helpers::inputOld($this->attributes['name']);
         }
         // Try populated values
         if (\Forma\Forma::hasValue($this->attributes['name'])) {
             $this->attributes['value'] = \Forma\Forma::getValue($this->attributes['name']);
         }
     }
     // Attributes
     foreach ($this->attributes as $a => $v) {
         if ($v !== null) {
             $tagString .= " " . $a . "=\"" . $this->encode($v) . "\"";
         } else {
             $tagString .= " " . $a;
         }
     }
     // End start tag
     $tagString .= ">";
     // Child tags
     if (count($this->childTags)) {
         foreach ($this->childTags as $t) {
             $tagString .= $t;
         }
         // Create end tag
         $tagString .= "</" . $this->tagName . ">";
     } elseif (isset($this->text)) {
         $tagString .= $this->rawText ? $this->text : $this->encode($this->text);
         // Create end tag
         $tagString .= "</" . $this->tagName . ">";
     }
     // Post-Renders
     foreach ($this->postRenders as $func) {
         $tagString .= $this->{$func}();
     }
     return $tagString;
 }
Example #4
0
 function __construct($name = null, $value = null)
 {
     parent::__construct($name, $value);
     $this->attributes['type'] = 'checkbox';
     // Try this request first
     if (\Forma\Helpers::input($this->attributes['name']) == $value) {
         $this->checked();
     }
     // Old input
     if (\Forma\Helpers::inputOld($this->attributes['name']) == $value) {
         $this->checked();
     }
     // Add pre-render
     $this->preRenders[] = 'preRenderCheckboxHidden';
 }
Example #5
0
 function __construct($name = null, $text = null)
 {
     $this->attributes['name'] = $name;
     if (!$text) {
         // Try this request first
         if (\Forma\Helpers::input($this->attributes['name'])) {
             $text = \Forma\Helpers::input($this->attributes['name']);
         }
         // Old input
         if (\Forma\Helpers::inputOld($this->attributes['name'])) {
             $text = \Forma\Helpers::inputOld($this->attributes['name']);
         }
     }
     $this->text = $text ? $text : '';
     // Add pre-renders for traits
     $this->preRenders[] = 'preRenderWithLabel';
 }
Example #6
0
 public function placeholder($text)
 {
     $this->attributes['placeholder'] = \Forma\Helpers::hasLang($text) ? \Forma\Helpers::lang($text) : $text;
     return $this;
 }
Example #7
0
 function __construct($text = null)
 {
     $this->text = \Forma\Helpers::hasLang($text) ? \Forma\Helpers::lang($text) : $text;
 }
Example #8
0
 public function action($action, $secure = true)
 {
     $this->attributes['action'] = \Forma\Helpers::url($action, array(), $secure);
     return $this;
 }