Esempio n. 1
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;
 }
Esempio n. 2
0
<?php

error_reporting(E_ALL);
require_once '../vendor/autoload.php';
use Forma\Forma;
$forma = new Forma();
echo "<pre>";
$user = new stdClass();
$user->email = '*****@*****.**';
$forma->populate($user);
echo htmlentities($forma->open('user', 'GET')->class('glenn')->class('bob')->attr('id', 'sweet')) . "\n";
echo htmlentities($forma->open_secure('user')->files()) . "\n";
echo htmlentities($forma->text('first_name', 'glenn<$@£$T£!^;')->class('form-control')->attr('id', 'first_name')) . "\n";
echo htmlentities($forma->text('last_name')->id('inputLast')->forceEmpty()) . "\n";
echo htmlentities($forma->email('email')->id('inputEmail')->required()) . "\n";
echo htmlentities($forma->password('password')->id('inputPassword')->allowValue()) . "\n";
echo htmlentities($forma->input('color')->type('color')->id('inputColor')) . "\n";
echo htmlentities($forma->checkbox('confirm', 1)->checked()) . "\n";
echo htmlentities($forma->open()->child($forma->checkbox('confirm', 1)->omitHidden())) . "\n";
echo htmlentities($forma->label()->child($forma->checkbox('confirm'))) . "\n";
echo htmlentities($forma->checkbox('confirm')->withLabel('Please Confirm')) . "\n";
echo htmlentities($forma->checkbox('confirm')->id('sweeeetID')->withLabel('Please Confirm')) . "\n";
echo htmlentities($forma->input('color')->type('color')->id('inputColor')->withLabel('Pick a color')) . "\n";
echo htmlentities($forma->checkbox('confirm')->id('inputConfirm')->wrap('Option One', array('class' => 'checkbox'))) . "\n";
echo htmlentities($forma->hidden('secret', 'thing')) . "\n";
echo htmlentities($forma->textarea('bio')) . "\n";
echo htmlentities($forma->textarea('secret', 'thi>ng<dd')->rows(10)) . "\n";
echo htmlentities($forma->textarea('secret', 'thi>ng<dd')->rows(10)->placeholder('Enter stuff')->withLabel('Stuff')) . "\n";
echo htmlentities($forma->radio('choice')->id('inputChoice')->wrap('Option One', array('class' => 'radio'))) . "\n";
echo htmlentities($forma->file('image')->id('inputFile')->wrap('Select Image')) . "\n";
echo htmlentities($forma->text('last_name')->id('inputLast')->placeholder('Enter last name')) . "\n";