Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #37 from moltin/feature/encrypted-field-type
Browse files Browse the repository at this point in the history
Adds encrypted field type to Flows
  • Loading branch information
anthonysterling committed Dec 14, 2015
2 parents d3d2020 + ae3abf1 commit 77aa471
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Flows.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ protected function typeText($a)
return '<textarea ' . $this->_buildArgs($this->args) . '>' . $value . '</textarea>';
}

protected function typeEncrypted($a)
{
$this->args['type'] = 'password';

return '<input ' . $this->_buildArgs($this->args) . ' />';
}

protected function _buildArgs($args, $skipValue = false)
{
$string = '';
Expand Down
21 changes: 21 additions & 0 deletions tests/FlowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ public function test_email_type()
$this->assertEquals('<input name="email" id="email" class="form-control" data-fieldtype="email" type="email" />', $flow['input']);
}

public function test_encrypted_type()
{
$field = array(
'name' => 'Password',
'slug' => 'password',
'type' => 'encrypted',
'options' => array(),
'required' => false,
);

$flow = $this->newBuiltFlowTypeFromField($field);

$this->assertEquals($field['name'], $flow['name']);
$this->assertEquals($field['slug'], $flow['slug']);
$this->assertEquals($field['type'], $flow['type']);
$this->assertEquals($field['options'], $flow['options']);
$this->assertEquals($field['required'], $flow['required']);

$this->assertEquals('<input name="password" id="password" class="form-control" data-fieldtype="encrypted" type="password" />', $flow['input']);
}

public function test_slug_type()
{
$field = array(
Expand Down

0 comments on commit 77aa471

Please sign in to comment.