Skip to content

Commit

Permalink
Merge pull request #2991 from marzochi/master
Browse files Browse the repository at this point in the history
datalist function for Text form field
  • Loading branch information
z-song committed Feb 8, 2019
2 parents d683c1b + 187c0c0 commit adb78f5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Form/Field/Text.php
Expand Up @@ -32,4 +32,14 @@ public function render()

return parent::render();
}

public function datalist( $entries = [] ) {
$this->defaultAttribute('list', "list-{$this->id}");
$datalist = "<datalist id=\"list-{$this->id}\">";
foreach($entries as $k => $v) {
$datalist .= "<option value=\"{$k}\">{$v}</option>";
}
$datalist .= "</datalist>";
$this->append($datalist);
}
}

0 comments on commit adb78f5

Please sign in to comment.