我想获得symfony Form的所有post参数.
我用了 :
$all_parameter = $this->get('request')->getParameterHolder()->getAll();
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
Fatal error: Call to undefined method Symfony\Component\HttpFoundation\Request::getParameterHolder() in /Library/WebServer/Documents/Symfony/src/Uae/PortailBundle/Controller/NoteController.php on line 95
Run Code Online (Sandbox Code Playgroud) 我在教义实体中有一个名为"birthday"的字段.
我想创建一个使用doctrine添加到数据库的对象.
控制器内部:
$name = "John Alex";
$birthday = "11-11-90";
$student = new Student();
$student->setName($name);
$student->setBirthday(strtotime($birthday);
...
Run Code Online (Sandbox Code Playgroud)
但是当我试图坚持下去时,我得到了这个错误
Fatal error: Call to a member function format() on a non-object in /Library/WebServer/Documents/Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateType.php on line 44
Run Code Online (Sandbox Code Playgroud)
编辑:
我的实体:
/**
* @var string $name
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var date $birthday
*
* @ORM\Column(name="birthday", type="date", nullable=true)
*/
private $birthday;
/**
* Set birthday
*
* @param date $birthday
*/
public function setBirthday($birthday)
{
$this->birthday = $birthday;
} …Run Code Online (Sandbox Code Playgroud) 我试图覆盖FOSUserBundle中的注册表单,但我收到此错误:我在官方文档中遵循了本教程: 链接
Could not load type "uae_user_registration"
Run Code Online (Sandbox Code Playgroud)
我的文件是:services.yml
# src/Uae/UserBundle/Resources/config/services.yml
services:
uae_user.registration.form.type:
class: Uae\UserBundle\Form\Type\RegistrationFormType
arguments: [%fos_user.model.user.class%]
tags:
- { name: form.type, alias: uae_user_registration }
Run Code Online (Sandbox Code Playgroud)
config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: Uae\UserBundle\Entity\User
registration:
form:
type: uae_user_registration
Run Code Online (Sandbox Code Playgroud)
RegistrationFormType:
<?php
#src/Uae/UserBundle/Form/Type/RegistrationType.php
namespace Uae\UserBundle\Form\Type;
use Symfony\Component\Form\FormBuilderInterface;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;
class RegistrationFormType extends BaseType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
parent::buildForm($builder, $options);
// add your custom field
$builder->add('nom');
$builder->add('prenom');
}
public function getName()
{
return 'uae_user_registration';
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Croppie Library将图像裁剪为cicle
我试图使用他们的函数返回base64编码的图像.它返回一个base64代码,但没有图像:这是我的代码:
<div id="vanilla-demo"></div>
</div>
<img id="myImage" src="">
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="croppie.js"></script>
<script type="text/javascript">
var vanilla = new Croppie(document.getElementById('vanilla-demo'), {
viewport: { width: 200, height: 200 , type:'circle'},
boundary: { width: 400, height: 400 },
showZoom: false
});
vanilla.bind('dac.jpg');
vanilla.result('canvas','original').then(function (src) {
console.log(src);
$('#myImage').attr('src', src);
});
</script>
Run Code Online (Sandbox Code Playgroud) 我有一个控制器函数,它返回一个带有值的响应,我想从twig调用这个控制器所以我使用:
{% render "UaePortailBundle:Note:isRempli" with { 'module_id' : module.id , 'year' : year } %}
Run Code Online (Sandbox Code Playgroud)
问题是我想将此返回值设置为变量"x"
我试过这个,但它不起作用.
{% set x = {% render "UaePortailBundle:Note:isRempli" with { 'module_id' : module.id , 'year' : year } %} %}
Run Code Online (Sandbox Code Playgroud) symfony ×4
doctrine-orm ×2
canvas ×1
crop ×1
croppie ×1
doctrine ×1
image ×1
javascript ×1
php ×1
twig ×1