Skip to content

Commit

Permalink
Merge pull request #21 from adamjudd/support-help-text
Browse files Browse the repository at this point in the history
Add support for help text
  • Loading branch information
robbieaverill authored Feb 18, 2018
2 parents a7d5a74 + 98a8e8a commit 2e2685d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/SegmentField.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class SegmentField extends TextField
*/
protected $preview = '';

/**
* @var string
*/
protected $helpText;

/**
* @param array $modifiers
*
Expand Down Expand Up @@ -146,4 +151,22 @@ protected function setModifierProperties(SegmentFieldModifier $modifier, $form,

return $this;
}

/**
* @param string $string The secondary text to show
* @return $this
*/
public function setHelpText($string)
{
$this->helpText = $string;
return $this;
}

/**
* @return string the secondary text to show in the template
*/
public function getHelpText()
{
return $this->helpText;
}
}
2 changes: 1 addition & 1 deletion templates/SilverStripe/Forms/SegmentField.ss
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
<button class="cancel btn btn-secondary btn-sm">
<%t SegmentField.Cancel 'Cancel' %>
</button>
<% if $HelpText %><p class="help">$HelpText</p><% end_if %>
<% if $HelpText %><p class="help form__field-description">$HelpText</p><% end_if %>
</div>

0 comments on commit 2e2685d

Please sign in to comment.