小编Bic*_*icu的帖子

Symfony表单只读字段

我应该如何read-only使用Symfony表单组件渲染字段?

这就是我试图这样做无济于事的方式:

Symfony 2

$builder
    ->add('descripcion', 'text', array(
        'read_only' =>'true'
    ));
}
Run Code Online (Sandbox Code Playgroud)

Symfony 3

$builder
    ->add('descripcion', TextType::class, array(
        'read_only' => 'true'
    ));
}
Run Code Online (Sandbox Code Playgroud)

symfony-forms symfony symfony-2.1

12
推荐指数
6
解决办法
3万
查看次数

控制器中的密码解码

我用它来编码我的密码:

 $entity->setSalt(md5(time()));
 $encoder = new MessageDigestPasswordEncoder('sha1');
 $password = $encoder->encodePassword($editForm->get('password')->getData(), $entity->getSalt());
 $entity->setPassword($password);
Run Code Online (Sandbox Code Playgroud)

但是如何才能重新开始呢?也就是说,我怎么能得到未加密的密码?如果我使用这个

$entity->getPassword()
Run Code Online (Sandbox Code Playgroud)

告诉我这个:

xOGjEeMdi4nwanOustbbJlDkug8=
Run Code Online (Sandbox Code Playgroud)

非常感谢你的答复.我正在尝试创建一个表单,用户输入旧密码并验证它是否为真.我有这样的形式:

            ->add('antigua', 'password', array('property_path' => false))
        ->add('password', 'repeated', array('first_name' => 'Nueva contraseña','second_name' => 'Repite contraseña','type' => 'password'));
Run Code Online (Sandbox Code Playgroud)

当我在crud中编辑用户时,我有:在更新操作中:

public function updateAction($id)
    {
        $em = $this->getDoctrine()->getEntityManager();

        $entity = $em->getRepository('miomioBundle:Empleado')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Empleado entity.');
        }

        $editForm   = $this->createForm(new EmpleadoType(), $entity);
        $deleteForm = $this->createDeleteForm($id);

        $request = $this->getRequest();
        **$entity->getPassword() is blank why?**
        $editForm->bindRequest($request);

        if ($editForm->isValid()){
            $em->persist($entity);
            $em->flush();
        }
            return $this->redirect($this->generateUrl('empleado_edit', array('id' => $id)));

        return …
Run Code Online (Sandbox Code Playgroud)

symfony

5
推荐指数
1
解决办法
9435
查看次数

symfony2 webprofiler显示prod环境

开发环境中的系统使用jquery进行的速度非常慢,但是我很好地将webprofiler放在prod环境中?问候和感谢

symfony

5
推荐指数
1
解决办法
5170
查看次数

将 PDF 存储在 MySQL 数据库中

我正在开发一个应用程序,我需要创建 PDF 格式的发票。我正在使用pdfbundle并且 PDF 文件已正确创建:

public function helloAction()
{
    $format = $this->get('request')->get('_format');
    $name = "work!!!";
    return $this->render(sprintf('miomioBundle:Venta:helloAction.%s.twig', $format), array('name' => $name));
}
Run Code Online (Sandbox Code Playgroud)

但我怎样才能将该文件存储在数据库中呢?

php pdf symfony twig

2
推荐指数
1
解决办法
2万
查看次数

symfony2.3过滤其他过滤器内的树枝

我有树枝过滤器:

class AcmeExtension extends \Twig_Extension
{
    public function getFilters()
    {
        return array(
            new \Twig_SimpleFilter('price', array($this, 'priceFilter')),
        );
    }

    public function priceFilter($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',')
    {
        $price = number_format($number, $decimals, $decPoint, $thousandsSep);
        $price = '$'.$price;

        return $price;
    }
}
Run Code Online (Sandbox Code Playgroud)

但如何在其他过滤器内调用价格过滤器?在symfony 2.0中声明过滤器 'price' => new \Twig_Filter_Method($this, 'priceFilter')

并且可以从另一个过滤器中调用它.

谢谢,抱歉我的英语

symfony twig

2
推荐指数
1
解决办法
1260
查看次数

标签 统计

symfony ×5

twig ×2

pdf ×1

php ×1

symfony-2.1 ×1

symfony-forms ×1