我想在两个条件下更新数据:
我有以下formHandler方法.
public function process(UserInterface $user)
{
$this->form->setData($user);
if ('POST' === $this->request->getMethod()) {
$password = trim($this->request->get('fos_user_profile_form')['password']) ;
// Checked where password is empty
// But when I remove the password field, it doesn't update anything.
if(empty($password))
{
$this->form->remove('password');
}
$this->form->bind($this->request);
if ($this->form->isValid()) {
$this->onSuccess($user);
return true;
}
// Reloads the user to reset its username. This is needed when the
// username or password have been changed to avoid issues with the
// security layer.
$this->userManager->reloadUser($user); …Run Code Online (Sandbox Code Playgroud) 我有以下模板代码。
<div class="row">
{% include 'ProductBundle:Partials:productInfo.html.twig' %}
{% include 'OrderBundle:Partials:orderInfo.html.twig' %}
{% include 'DeliveryBundle:Partials:deliveryInfo.html.twig' %}
{% include 'BillBundle:Partials:billInfo.html.twig' %}
</div>
Run Code Online (Sandbox Code Playgroud)
我想展示ROLE_USER. 他无法访问其他三个包括。其他用户ROLE_ADMIN可以访问所有四个包含部分。
有没有办法用树枝做到这一点?