Skip to content

Commit

Permalink
Solving issue #50
Browse files Browse the repository at this point in the history
  • Loading branch information
netojose committed Jan 17, 2019
1 parent b59d4e2 commit f07fc04
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function open(): string
if ($this->_Fmethod !== 'get') {
$ret .= csrf_field();

if ($this->_Fmethod !== 'post') {
if ($this->_Fmethod !== 'post' && $this->_Fmethod !== 'get') {
$ret .= method_field($this->_Fmethod);
}
}
Expand Down Expand Up @@ -649,20 +649,32 @@ private function _getLabel(): string
*/
private function _buildAttrs(array $props = [], array $ignore = []): string
{
$props = array_merge(array_filter($this->_attrs, function($k){
return $k != 'class';
}, ARRAY_FILTER_USE_KEY), $props);

$props['type'] = $this->_type;
$props['name'] = $this->_name;
if($this->_type){
$props['type'] = $this->_type;
}

if($this->_name){
$props['name'] = $this->_name;
}

if (!is_null($this->_autocomplete)) {
$props['autocomplete'] = $this->_autocomplete;
} else if (isset($this->_allowedAutoComplete[$props['name']])) {
$props['autocomplete'] = $props['name'];
} else if ($this->_name && isset($this->_allowedAutoComplete[$this->_name])) {
$props['autocomplete'] = $this->_name;
}

$id = $this->_getId();
if($id){
$props['id'] = $this->_getId();
}

$props['id'] = $this->_getId();
$props['class'] = isset($props['class']) ? $props['class'] : '';

if ($this->_type == 'select' && $this->_multiple) {
if ($this->_type == 'select' && $this->_multiple && $this->_name) {
$props['name'] = $props['name'] . '[]';
}

Expand Down

0 comments on commit f07fc04

Please sign in to comment.