我尝试使用SonataFormatterBundle,尤其是sonata_simple_formatter_type。 我按照这里的确切文档:https://sonata-project.org/bundles/formatter/3-x/doc/reference/installation.html
所以,这是var whosTurn = 'x';
function whoIsTurn(){
if(whosTurn == 'x'){
whosTurn = 'o';
} else {
whosTurn = 'x';
}
return whosTurn;
}
function ticTac(){
if (this.innerHTML == "-"){
this.innerHTML = whoIsTurn();
}
}
document.getElementById("c1").onclick = ticTac;
document.getElementById("c2").onclick = ticTac;
document.getElementById("c3").onclick = ticTac;
document.getElementById("c4").onclick = ticTac;
document.getElementById("c5").onclick = ticTac;
document.getElementById("c6").onclick = ticTac;
document.getElementById("c7").onclick = ticTac;
document.getElementById("c8").onclick = ticTac;
document.getElementById("c9").onclick = ticTac;
:
config.yml
以下是# Twig Configuration
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes:
- 'SonataFormatterBundle:Form:formatter.html.twig'
sonata_admin:
title: Artisan du bonheur
title_logo: favicon.ico
templates:
layout: SonataAdminBundle::layout.html.twig
sonata_formatter:
default_formatter: richhtml
formatters:
markdown:
service: sonata.formatter.text.markdown
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig #keep this commented unless you are using media bundle.
text:
service: sonata.formatter.text.text
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig
rawhtml:
service: sonata.formatter.text.raw
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig
richhtml:
service: sonata.formatter.text.raw
extensions:
- sonata.formatter.twig.control_flow
- sonata.formatter.twig.gist
# - sonata.media.formatter.twig
twig:
service: sonata.formatter.text.twigengine
extensions: [] # Twig formatter cannot have extensions
:
app/Resources/SonataAdminBundle/views/layout.html.twig
最后,这是我的{% extends 'SonataAdminBundle::standard_layout.html.twig' %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{asset('bundles/sonataformatter/markitup/skins/sonata/style.css') }}" type="text/css" media="all" />
<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/sets/markdown/style.css') }}" type="text/css" media="all" />
<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/sets/html/style.css') }}" type="text/css" media="all" />
<link rel="stylesheet" href="{{ asset('bundles/sonataformatter/markitup/sets/textile/style.css') }}" type="text/css" media="all" />
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('bundles/ivoryckeditor/ckeditor.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/vendor/markitup-markitup/markitup/jquery.markitup.js') }}" type="text/javascript"</script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/markdown/set.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/html/set.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/textile/set.js') }}" type="text/javascript"></script>
{% endblock %}
课程:
RenseignementAdmin
顺便说一句,无论我在protected function configureFormFields(FormMapper $formMapper)
{
$formMapper ->add('title')
->add('content', 'sonata_simple_formatter_type', array(
'format' => 'richhtml'
)
);
}
选项中使用而不是richhtml,我觉得他并不关心,因为我确实放了像'format'
bob
这样的东西仍在显示基本文本输入。
我哪里出错了?