Updating the admin login page for sonatauser

I am trying to modify the page admin login in sonatauser, located at sonataproject/userbundle/admin/Resources/views/admin/security/login.html.twig. However, I am facing difficulty as the file extends the base template. Does anyone have a solution for this issue?

{% extends base_template %}

{% block content %}
    <div class="connection">
        <form action="{{ path("sonata_user_admin_security_check") }}" method="post">

            {% if error %}
                <div class="alert alert-error">{{ error|trans({}, 'SonataUserBundle') }}</div>
            {% endif %}

            <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />

            <div class="control-group">
                <label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>

                <div class="controls">
                    <input type="text" id="username" name="_username" value="{{ last_username }}" class="big sonata-medium"/>
                </div>
            </div>

            <div class="control-group">
                <label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>

                <div class="controls">
                    <input type="password" id="password" name="_password" class="big sonata-medium" />
                </div>
            </div>

            <div class="control-group">
                <label for="remember_me">
                    <input type="checkbox" id="remember_me" name="_remember_me" value="on" />
                    {{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
                </label>
            </div>

            <div class="form-actions">
                <input type="submit" class="btn btn-primary" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
            </div>
        </form>
    </div>
{% endblock content %}

Answer №1

To customize the login template in SonataUserBundle, you will need to extend the bundle.

Refer to the documentation for instructions on how to install an extended version of SonataUserBundle. If you do not have access to the sonata:easy-extends:generate command, consider installing SonataEasyExtendsBundle.

Create a file named login.html.twig in Application/Sonata/UserBundle/Resources/views/Admin/Security and insert the default code (for SonataUserBundle 2.2) which can then be customized as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Mysql coding for search engines utilizing names

I am trying to create a search engine in PHP that searches for people using their first and last names, each stored in separate columns. Currently, I am using the following SQL query: SELECT * FROM users WHERE first_name OR last_name LIKE '$search_ ...

Send form without reloading the page (partially updating the page)

Code snippet in index.php HTML head: <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> <script src="http://malsup.github.com/jquery.form.js"></script> <script> // Ensurin ...

Discover the logged-in user's email address utilizing LDAP/PHP

Is it possible to extract the user's email address from PHP after successful authentication using AuthLDAPURL in the htaccess file? ...

What is the reason for storing CRUD images in a temporary file?

When working on my Laravel application, I encountered an issue where the photo of a new book was being sent to a temporary file instead of the specified destination path. What could be causing this? Here are my functions: public function store(Request $re ...

What is the best method to incorporate JavaScript into all pages of a website?

Interested in incorporating "Google Analytics" on your website? I just finished configuring my Google Analytics, but the final step is to insert the tracking code into every page I want to track. The code provided is: <script> (function(i,s,o,g,r ...

I encountered a difficulty when trying to update form data in MySQL utilizing PHP and jQuery

So here's the situation: I've managed to insert and delete records from a form using jQuery and PHP scripts to interact with a MYSQL database. However, I'm facing a challenge when it comes to updating data that has been retrieved from the da ...

Modifying the key values of an associative array

In my code snippet, I am attempting to loop through a JSON array and update the values within it. Here is an overview of what the JSON structure looks like: <?php $json='[{"type":"dropdown","label":"Is the property tenanted ?","req":0,"choices":[{ ...

PHP: Removing elements within a foreach loop

$array = array('1','3','20','10'); foreach ($array as $i=>$arr) { if ($i==0) unset($array[$i]); } Query: If an element is removed from the array, will it affect the order of iteration in this loop? What will h ...

Encountering a 500 server error while attempting to retrieve content from Google Images through the Web Speech API

My current project involves utilizing the Web Speech API to dynamically gather free images from Google. Here's how it works: I extract the search keyword using the Web Speech API in JavaScript. The keyword is then sent to the server (PHP) via an a ...

Using UTF-8 encoding for Hebrew characters and large question marks

I have gone through numerous articles, but the concept is still not clear to me. I am currently retrieving text from a file using the following code snippet: $fp = fopen($storagename, 'r'); while ( !feof($fp) ){ $line = fgets($fp, 2048); ...

Retrieve the range of dates starting from the day of birth

I am currently working on developing a peers page for my website. I need assistance in creating a query that can retrieve users from the users table, which is organized as id, name, gender, dob. The query should fetch users based on their date of birth i ...

The PDO MySQL error HY093 was thrown due to an incorrect number of parameters being passed

Encountering an HY093 (Parameter count mismatch) SQLSTATE error on a query that seems to have the correct number of parameters. Here is a complete PHP script to reproduce the issue. (Remember to update the database credentials.) The SELECT statement conta ...

Step-by-step guide to showcasing and refreshing input values retrieved from the database in Laravel

How can I allow users to update their profile information displayed in input fields pulled from the database? Controller.php // Display user details in input field Public function userDetails() { $id = auth()->id; $details = Users::where(' ...

How can I create a loop to iterate through form/input files with varying titles?

Looping through input files with different titles Hello, I am trying to figure out how to loop through an input file with different titles. Each input file has a unique title, such as Safety Data Sheet, Certificate, etc. This is my current code: $titles ...

The function $helper->getSessionFromRedirect() consistently comes back empty

It seems that I'm facing an issue where `getsessionformredirect` always returns null. The log output shows "session = " returning null. Despite looking through various threads and trying out different Facebook login example files, I haven't been ...

The Laravel system does not support calling the non-static method AppHttpModelsRole::id_role() in a static manner

Looking for assistance with creating a custom middleware in Laravel for login. I'm specifically trying to retrieve the Role using middleware, but running into some issues. class CheckRole { public function handle($request, Closure $next) { ...

The problem lies in the incorrect rewriting of static resources leading them to be redirected to the

I am currently facing an issue with rewriting URLs. It seems that the problem lies in the redirection of certain URLs to index.php?route=scores, etc. http://www.example.com/scores http://www.example.com/registreren http://www.example.com/login This redir ...

Update the form action URL when a specific option is selected from the dropdown menu upon clicking the submit

I would like my form to redirect to a specific page on my website based on the selection made in the <select> tag. For instance, if '2checkout' is selected, it should go to gateways/2checkout/2checkout.php. Similarly, if 'Payza' i ...

Transform your MySQL data into JSON format effortlessly by harnessing the power of PHP,

Code <?php include "dbconfig.php"; include "yrsetup.php"; $tdate='2018-11-19'; $tmarket='sirsi'; $sql="SELECT ALLCODES.NAME AS Type,MIN(LOT1819.RATE) AS Min,MAX(LOT1819.RATE) AS Max,ROUND(SUM(LOT1819.RATE)/COUNT(LOTNO),0) AS avg F ...

Is mysql(i)_real_escape_string a reliable method for ensuring data safety?

function CustomQuery() { $arguments = func_get_args (); if (sizeof ($arguments) > 0) { $query_string = $arguments[0]; for ($index = 1; $index < sizeof ($arguments); $index++) $query_string = preg_replac ...