diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-11-13 22:51:59 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-11-13 22:51:59 -0500 |
commit | ebb6b2827d0496303852f524a551592295dd0040 (patch) | |
tree | a3e6dff7036ba83e436941b0b0e96c89311eb0f8 /app/Helper/FormHelper.php | |
parent | 527a1677a0578e479302e1f80b127e177ed915e9 (diff) |
Replace SimpleMDE with custom Markdown editor
Diffstat (limited to 'app/Helper/FormHelper.php')
-rw-r--r-- | app/Helper/FormHelper.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/Helper/FormHelper.php b/app/Helper/FormHelper.php index eca1f317..6d915526 100644 --- a/app/Helper/FormHelper.php +++ b/app/Helper/FormHelper.php @@ -182,6 +182,44 @@ class FormHelper extends Base } /** + * Display a markdown editor + * + * @access public + * @param string $name Field name + * @param array $values Form values + * @param array $errors Form errors + * @param array $attributes + * @return string + */ + public function textEditor($name, $values = array(), array $errors = array(), array $attributes = array()) + { + if (! isset($attributes['css'])) { + $attributes['css'] = ''; + } + + $attrHtml = ''; + $attributes['css'] .= $this->errorClass($errors, $name); + + foreach ($attributes as $attribute => $value) { + $attrHtml .= sprintf(' %s="%s"', $attribute, $value); + } + + $html = sprintf( + '<texteditor name="%s" text="%s" label-preview="%s" label-write="%s" placeholder="%s" %s></texteditor>', + $name, + isset($values[$name]) ? $this->helper->text->e($values[$name]) : '', + t('Preview'), + t('Write'), + t('Write your text in Markdown'), + $attrHtml + ); + + $html .= $this->errorList($errors, $name); + + return $html; + } + + /** * Display file field * * @access public |