Skip to content

Commit

Permalink
fixed code
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed May 15, 2015
1 parent 6669eab commit ff9338c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"issues": "https://github.com/oscarotero/form-manager-bootstrap/issues"
},
"require": {
"form-manager/form-manager": ">=4.3.5"
"form-manager/form-manager": "4.3.*"
},
"autoload": {
"psr-4": {
Expand Down
9 changes: 7 additions & 2 deletions demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
'year' => 'col-sm-4 col-md-3'
]
]),
'colors' => Bootstrap::choose([
'red' => Bootstrap::radio()->label('Red'),
'blue' => Bootstrap::radio()->label('Blue'),
'green' => Bootstrap::radio()->label('Green')
]),
'reset' => Bootstrap::submit()->val('ola')->html('ola'),
'submit' => Bootstrap::submit()->html('Send')
]);
Expand All @@ -36,8 +41,8 @@
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="bower_components/bootstrap/dist/css/bootstrap-theme.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>

<body>
Expand Down
51 changes: 25 additions & 26 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,34 @@ public static function getTemplate($field)
return 'formColumnSizingTemplate';
}

if (!($input = $field->input)) {
if ($field instanceof Containers) {
return false;
}

switch ($input->getElementName()) {
case 'textarea':
case 'select':
return 'formGroupTemplate';

case 'button':
return 'buttonTemplate';

case 'input':
switch ($input->attr('type')) {
case 'checkbox':
case 'radio':
return 'radioCheckboxTemplate';

case 'submit':
case 'reset':
case 'button':
return 'buttonTemplate';

default:
return 'formGroupTemplate';
}
if ($field instanceof Fields\Field) {
switch ($field->input->getElementName()) {
case 'textarea':
case 'select':
return 'formGroupTemplate';

case 'button':
return 'buttonTemplate';

case 'input':
switch ($field->input->attr('type')) {
case 'checkbox':
case 'radio':
return 'radioCheckboxTemplate';

case 'submit':
case 'reset':
case 'button':
return 'buttonTemplate';

default:
return 'formGroupTemplate';
}
}
}
}

Expand Down Expand Up @@ -318,9 +320,6 @@ private static function getRadioCheckHtml($field)
$field->errorLabel->addClass('text-danger');
}

//Generates random id if not defined
$field->input->id();

$html = $field->input->toHtml();
$html = $field->label->toHtml($html.' ').$field->errorLabel;
$html = Element::div(true)->class($field->input->attr('type'))->toHtml($html);
Expand Down

0 comments on commit ff9338c

Please sign in to comment.