我正在使用Doctrine 2和Symfony 2.3以及jQuery UI进行排序.
我有一个可以使用jQuery排序的元素列表,并且位置通过Ajax请求保存在数据库中.
除了数据持久性之外,所有似乎都工作得很好......元素的位置和数据库中与其相关的其他元素是错误的.
示例:
| ID | POSITION | TITLE
| 1 | 0 | Element 1
| 2 | 1 | Element 2
| 3 | 2 | Element 3
| 4 | 3 | Element 4
Run Code Online (Sandbox Code Playgroud)
如果我将ID 3(位置3)移动到位置0,我将在数据库中得到以下结果:
| ID | POSITION | TITLE
| 1 | 2 | Element 1
| 2 | 2 | Element 2
| 3 | 0 | Element 3
| 4 | 4 | Element 4
Run Code Online (Sandbox Code Playgroud)
我检查了,插入的值是正确的(0).
我正在使用此代码更新位置:
$pyramid …Run Code Online (Sandbox Code Playgroud) 我想在Symfony2表单中添加HTML5颜色输入类型(目前仅由Chrome支持).我创建了一个从文本类型继承的新颜色类型:
<?php
namespace Marquis\WebsiteBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
class ColorType extends AbstractType
{
public function getParent()
{
return 'text';
}
public function getName()
{
return 'color';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
并创建了一个新服务来使用它:
marquis_website.form.type.color:
class: Marquis\WebsiteBundle\Form\Type\ColorType
tags:
- { name: form.type, alias: color }
Run Code Online (Sandbox Code Playgroud)
但是,当显示表单时,输入标记如下所示:
<input type="text" id="entity_hex" name="entity[hex]" value="#4D89BF">
Run Code Online (Sandbox Code Playgroud)
所以它不是使用新的HTML5颜色输入而是使用文本输入.
有没有办法覆盖类型,所以它会显示type ="color"?
我还检查了fields.html.twig,这条线应该可以正常工作:
{% set type = type|default('text') %}
Run Code Online (Sandbox Code Playgroud)
如果我将默认值('text')更改为默认值('color'),则所有input type ="text"都将更改为type ="color".
谢谢您的帮助,
我最近重新开了一个旧的(1年)Symfony项目,我在每一页都有错误(我不记得一年前有这个问题):
[exception] 500 | Internal Server Error | Symfony\Component\Config\Exception\FileLoaderLoadException
/var/www/[...]/wdt.xml
ContextErrorException: Notice: Undefined property: DOMDocument::$documentElement
Run Code Online (Sandbox Code Playgroud)
如果我清除缓存,则错误消失但是一旦我编辑并保存文件,错误就会再次出现.该项目使用Symfony 2.8,我更新到Symfony 3.2,但它没有解决问题.
我不认为这个问题与wdt.xml文件有关,我认为它可能与我的笔记本电脑配置有关.
我真的不知道从哪里开始调查,所以欢迎任何建议!
编辑1:
我实际上遇到了与我几天前创建的另一个项目相同的问题.该项目不使用任何其他捆绑包,我只创建了5个实体并生成了MySQL数据库.
编辑2:
经过一些研究,我决定创建一个新的Ubuntu VM并测试一个新的Symfony项目,它只是完美的工作,所以它必须与我的笔记本电脑上的配置有关.
编辑3:
经过一些更多的测试,这是我添加print_r($ dom)时得到的; 在文件XmlUtils.php(vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php)第59行:
Ubuntu VM(没有错误):
DOMDocument Object ( [doctype] => [implementation] => (object value omitted) [documentElement] => (object value omitted) [actualEncoding] => [encoding] => [xmlEncoding] => [standalone] => 1 [xmlStandalone] => 1 [version] => 1.0 [xmlVersion] => 1.0 [strictErrorChecking] => 1 [documentURI] => /var/www/my_project/web/ [config] => [formatOutput] => [validateOnParse] => 1 …Run Code Online (Sandbox Code Playgroud)