コード例 #1
0
ファイル: ZurbFoundation.php プロジェクト: autocar/former
 /**
  * Render a disabled field
  *
  * @param Field $field
  *
  * @return Input
  */
 public function createDisabledField(Field $field)
 {
     $field->disabled();
     return Input::create('text', $field->getName(), $field->getValue(), $field->getAttributes());
 }
コード例 #2
0
ファイル: File.php プロジェクト: aleguisf/fvdev1
 /**
  * Prints out the current tag
  *
  * @return string An input file tag
  */
 public function render()
 {
     // Maximum file size
     $hidden = $this->maxSize ? HtmlInput::hidden('MAX_FILE_SIZE', $this->maxSize) : null;
     return parent::render() . $hidden;
 }
コード例 #3
0
ファイル: Checkable.php プロジェクト: aleguisf/fvdev1
 /**
  * Renders a checkable
  *
  * @param string|array $item          A checkable item
  * @param integer   $fallbackValue A fallback value if none is set
  *
  * @return string
  */
 protected function createCheckable($item, $fallbackValue = 1)
 {
     // Extract informations
     extract($item);
     // Set default values
     if (!isset($attributes)) {
         $attributes = array();
     }
     if (isset($attributes['value'])) {
         $value = $attributes['value'];
     }
     if (!isset($value) or $value === $this->app['former']->getOption('unchecked_value')) {
         $value = $fallbackValue;
     }
     // If inline items, add class
     $isInline = $this->inline ? ' ' . $this->app['former.framework']->getInlineLabelClass($this) : null;
     // Merge custom attributes with global attributes
     $attributes = array_merge($this->attributes, $attributes);
     if (!isset($attributes['id'])) {
         $attributes['id'] = $name . $this->unique($name);
     }
     // Create field
     $field = Input::create($this->checkable, $name, $value, $attributes);
     if ($this->isChecked($item, $value)) {
         $field->checked('checked');
     }
     // Add hidden checkbox if requested
     if ($this->isOfType('checkbox', 'checkboxes')) {
         if ($this->isPushed or $this->app['former']->getOption('push_checkboxes') and $this->isPushed !== false) {
             $field = $this->app['former']->hidden($name)->forceValue($this->app['former']->getOption('unchecked_value')) . $field->render();
         }
     }
     // If no label to wrap, return plain checkable
     if (!$label) {
         return is_object($field) ? $field->render() : $field;
     }
     return Element::create('label', $field . $label)->for($attributes['id'])->class($this->checkable . $isInline);
 }
コード例 #4
0
ファイル: TagTest.php プロジェクト: Geekathon/reddit-clone
 public function testCanUseXhtmlStandards()
 {
     Tag::$config['doctype'] = 'xhtml';
     $field = Input::hidden('foo', 'bar');
     $this->assertContains(' />', $field->render());
 }
コード例 #5
0
ファイル: Checkable.php プロジェクト: autocar/former
 /**
  * Renders a checkable
  *
  * @param string|array $item          A checkable item
  * @param integer      $fallbackValue A fallback value if none is set
  *
  * @return string
  */
 protected function createCheckable($item, $fallbackValue = 1)
 {
     // Extract informations
     extract($item);
     // Set default values
     if (!isset($attributes)) {
         $attributes = array();
     }
     if (isset($attributes['value'])) {
         $value = $attributes['value'];
     }
     if (!isset($value) or $value === $this->app['former']->getOption('unchecked_value')) {
         $value = $fallbackValue;
     }
     // If inline items, add class
     $isInline = $this->inline ? ' ' . $this->app['former.framework']->getInlineLabelClass($this) : null;
     // In Bootsrap 3, don't append the the checkable type (radio/checkbox) as a class if
     // rendering inline.
     $class = $this->app['former']->framework() == 'TwitterBootstrap3' ? trim($isInline) : $this->checkable . $isInline;
     // Merge custom attributes with global attributes
     $attributes = array_merge($this->attributes, $attributes);
     if (!isset($attributes['id'])) {
         $attributes['id'] = $name . $this->unique($name);
     }
     // Create field
     $field = Input::create($this->checkable, $name, $value, $attributes);
     if ($this->isChecked($item, $value)) {
         $field->checked('checked');
     }
     // Add hidden checkbox if requested
     if ($this->isOfType('checkbox', 'checkboxes')) {
         if ($this->isPushed or $this->app['former']->getOption('push_checkboxes') and $this->isPushed !== false) {
             $field = $this->app['former']->hidden($name)->forceValue($this->app['former']->getOption('unchecked_value')) . $field->render();
             // app['former.field'] was overwritten by Former::hidden() call in the line above, so here
             // we reset it to $this to enable $this->app['former']->getErrors() to retrieve the correct object
             $this->app->instance('former.field', $this);
         }
     }
     // If no label to wrap, return plain checkable
     if (!$label) {
         $element = is_object($field) ? $field->render() : $field;
     } else {
         $element = Element::create('label', $field . $label)->for($attributes['id'])->class($class)->render();
     }
     // If BS3, if checkables are stacked, wrap them in a div with the checkable type
     if (!$isInline && $this->app['former']->framework() == 'TwitterBootstrap3') {
         $wrapper = Element::create('div', $element)->class($this->checkable);
         if ($this->getAttribute('disabled')) {
             $wrapper->addClass('disabled');
         }
         $element = $wrapper->render();
     }
     // Return the field
     return $element;
 }
コード例 #6
0
ファイル: Hidden.php プロジェクト: Vrian7ipx/repocas
 /**
  * Outputs a hidden field
  *
  * @return string An <input type="hidden" />
  */
 public function render()
 {
     return HtmlInput::create('hidden', $this->name, $this->value, $this->attributes)->render();
 }
コード例 #7
0
ファイル: Hidden.php プロジェクト: laralite/form
 /**
  * Outputs a hidden field
  *
  * @return string An <input type="hidden" />
  */
 public function render()
 {
     return HtmlInput::create('hidden', $this->name, Helpers::encode($this->value), $this->attributes)->render();
 }
コード例 #8
0
 public function testCanHaveSelfClosingChildren()
 {
     $tag = Element::div('foo')->nest(array('foo' => Input::create('text')));
     $this->assertEquals('<div>foo<input type="text"></div>', $tag->render());
 }
コード例 #9
0
ファイル: InputTest.php プロジェクト: Geekathon/reddit-clone
 public function testMinCanBeZero()
 {
     $input = Input::create('number', 'foo', 0)->min(0)->max(100)->render();
     $matcher = '<input type="number" name="foo" min="0" max="100" value="0">';
     $this->assertEquals($matcher, $input);
 }