Exemple #1
0
 /**
  * Test turning a string into an id
  *
  * @return void
  * @author Dan Cox
  */
 public function test_id()
 {
     $id1 = Str::id('Foo bar');
     $id2 = Str::id('(*&!^@(*@)(@ my id');
     $this->assertEquals('foo_bar', $id1);
     $this->assertEquals('my_id', $id2);
 }
Exemple #2
0
 /**
  * Create the relevent fields
  *
  * @param String $label
  * @param String $type
  * @param \Wasp\Forms\FieldOutput\AbstractFieldOutput $output
  * @param String $id
  * @param Array $rules
  * @param String $default
  * @param Array|String $values
  * @param Array $input
  * @author Dan Cox
  */
 public function __construct($label, $type = 'text', $output = NULL, $id = '', array $rules = array(), $default = '', $values = array(), $input = array())
 {
     $this->label = $label;
     $this->type = $type;
     $this->output = !is_null($output) ? $output : 'Wasp\\Forms\\FieldOutput\\InputStringOutput';
     $this->id = $id !== '' ? $id : Str::id($label);
     $this->values = $values;
     $this->default = $default;
     $this->rules = new Collection($rules);
     $this->input = $input;
     $this->errors = new Collection();
     $this->extractValue();
 }