Пример #1
0
 /**
  * Set up a Field instance
  *
  * @param string $type A field type
  */
 public function __construct($type, $name, $label, $value, $attributes)
 {
     // Set base parameters
     $this->attributes = (array) $attributes;
     $this->label = $label;
     $this->name = $name;
     $this->type = $type;
     $this->value = $value;
     // Set magic parameters (repopulated value, translated label, etc)
     if (Config::get('automatic_label')) {
         $this->ponder($name, $label);
     }
     if ($type != 'password') {
         $this->value = $this->repopulate();
     }
     if (Config::get('live_validation')) {
         $this->addRules();
     }
     // Link Control group
     if (Framework::isnt(null)) {
         $this->controlGroup = new ControlGroup($this->label);
     }
 }
Пример #2
0
 /**
  * Append an icon to a field
  *
  * @param string $icon       The icon to prepend
  * @param array  $attributes Its attributes
  */
 public function appendIcon($icon, $attributes = array())
 {
     $icon = Framework::icon($icon, $attributes);
     $this->placeAround($icon, 'append');
 }
Пример #3
0
 /**
  * Add an block help
  *
  * @param  string $help       The help text
  * @param  array  $attributes Facultative attributes
  */
 public function blockHelp($help, $attributes = array())
 {
     // If no help text, do nothing
     if (empty($help)) {
         return false;
     }
     // Attempt to translate help text
     $help = Helpers::translate($help);
     $this->help['block'] = Framework::blockHelp($help, $attributes);
 }
Пример #4
0
 public function testChangeViaFormer()
 {
     Former::framework('zurb');
     $this->assertEquals(Framework::current(), 'zurb');
 }
Пример #5
0
<?php

use Former\Config;
use Former\Framework;
// Loading Former -------------------------------------------------- /
Autoloader::namespaces(array('Former' => Bundle::path('former') . 'libraries'));
// Loading Former configuration ------------------------------------ /
// Fetch configuration files
new Config();
// Set default framework
Framework::useFramework(Config::get('framework'));
Пример #6
0
 public static function renderLabel($label, $field)
 {
     // Get the label and its informations
     extract($label);
     // Add classes to the attributes
     $attributes = Framework::getLabelClasses($attributes);
     // Append required text
     if ($field->isRequired()) {
         $label .= Config::get('required_text');
     }
     // Get the field name to link the label to it
     if ($field->isCheckable()) {
         return '<label' . HTML::attributes($attributes) . '>' . $label . '</label>';
     }
     return \Form::label($field->name, $label, $attributes);
 }