我想在我的 symfony 项目中使用 tinymce 在我定义这个编辑器之前我可以从表单中读取并在我定义 tinymce 并将选择器设置为我的树枝文件上方的 textarea 后写入数据库
{# src/MY/FilmBundle/Resources/views/Page/newfilm.html.twig #}
{% extends 'MYFilmBundle::layout.html.twig' %}
{% block javascripts %}
<script type="text/javascript" src="{{asset('tinymce/jscripts/tiny_mce/tiny_mce.js')}}"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea"
});
</script>
{% endblock %}
{% block body %}
<form action="{{ path('MYFilmBundle_submitNewFilm') }}" method="post" {{ form_enctype(form) }} class="movie">
{{ form_errors(form) }}
{{ form_row(form.text)}}
{{ form_rest(form) }}
<input type="submit" value="{{ 'Submit'}}" />
</form>
{% endblock %}
并将此代码添加到 buildfilmform (php 类) 我无法从表单中读取
class buildfilmform extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('text', 'textarea')
}
public function getName()
{ // return a unique identifier
return 'MY_filmbundle_buildfilmform';
}
}
读取表单并保存到数据库的操作:
public function submitNewFilmAction()
{
$em = $this->getDoctrine()->getEntityManager();
$newFilm = new Film();
$user = $this->getUser();
$user_obj = $em->getRepository('MYFilmBundle:Author')->find($user);
$newFilm->setAuthor($user);
$form = $this->createForm(new buildfilmform(), $newFilm);
$form->bind($this->getRequest());
if ($form->isValid()) {
$film = $form->getData();
$em->persist($film);
$em->flush();
return $this->redirect($this->generateUrl('MYFilmBundle_homepage'));
}
return $this->render(
'MYFilmBundle:Page:newfilm.html.twig', array(
'form' => $form->createView(),
));
}
我不知道我怎么能用
// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());
// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});
// Get content of a specific editor:
tinyMCE.get('content id').getContent()
你能帮助我吗?
多谢
ps:我在我的项目中添加了tinymce-dev,我想知道我怎样才能在我的项目中使用上面的代码