Skip to content

Commit

Permalink
Tidying up pull request.
Browse files Browse the repository at this point in the history
Many thanks to Anahkiasen :)
  • Loading branch information
Tortue Torche committed Jan 21, 2014
1 parent 1e5fd84 commit 2278185
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
21 changes: 20 additions & 1 deletion src/Former/Framework/TwitterBootstrap3.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ public function errorState()
return 'has-error';
}

/**
* Returns corresponding inline class of a field
*
* @param Field $field
*
* @return string
*/
public function getInlineLabelClass($field)
{
$inlineClass = 'inline';
if ($field->isOfType('checkbox', 'checkboxes')) {
$inlineClass = 'checkbox-'.$inlineClass;
} elseif ($field->isOfType('radio', 'radios')) {
$inlineClass = 'radio-'.$inlineClass;
}

return $inlineClass;
}

/**
* Set the fields width from a label width
*
Expand Down Expand Up @@ -185,7 +204,7 @@ protected function setFieldWidths($labelWidths)
public function getFieldClasses(Field $field, $classes)
{
// Add inline class for checkables
if ($field->isCheckable() and count(array_intersect(array('inline', 'checkbox-inline', 'radio-inline'), $classes)) > 0) {
if ($field->isCheckable() and in_array('inline', $classes)) {
$field->inline();
}

Expand Down
13 changes: 1 addition & 12 deletions src/Former/Traits/Checkable.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,18 +309,7 @@ protected function createCheckable($item, $fallbackValue = 1)
}

// If inline items, add class
$isInline = null;
if ($this->inline) {
$inlineClass = 'inline';
if ($this->app['former.framework']->current() === 'TwitterBootstrap3') {
if ($this->isOfType('checkbox', 'checkboxes')) {
$inlineClass = 'checkbox-'.$inlineClass;
} elseif ($this->isOfType('radio', 'radios')) {
$inlineClass = 'radio-'.$inlineClass;
}
}
$isInline = ' '.$inlineClass;
}
$isInline = $this->inline ? ' '.$this->app['former.framework']->getInlineLabelClass($this) : null;

// Merge custom attributes with global attributes
$attributes = array_merge($this->attributes, $attributes);
Expand Down
13 changes: 13 additions & 0 deletions src/Former/Traits/Framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@ public function errorState()
return 'error';
}


/**
* Returns corresponding inline class of a field
*
* @param Field $field
*
* @return string
*/
public function getInlineLabelClass($field)
{
return 'inline';
}

/**
* Set framework defaults from its config file
*/
Expand Down

0 comments on commit 2278185

Please sign in to comment.