How to Allow the File Input Type to Accept Only Image Files
If you use <input type="file">, it will accept all file types. But it is possible to restrict the file types to only images, or certain image file extensions. To achieve this, you need to use the HTML accept attribute. This attribute is only used with <input type="file"> and serves as a filter to select file inputs from the file input dialog box.
How to Center an Image with the CSS text-align Property
In general, you cannot use the CSS text-align property to center an image, as it works only on block elements, and the <img> is an inline one. But there is a trick that will help you to center the image with the text-align property. If you need this property for some reasons, you can add a <div> element and specify the text-align property on it. Use the “center” value of this property.
How to Align Labels Next to Inputs
When you create a web form, you’ll probably need to know how to align labels with inputs. Here, we’ll show how it’s possible to create right-aligned and left-aligned <label> elements next to inputs.
How to Make a Back to Top Button
You've probably seen a "back-to-top" button at the bottom-right corner on many websites when you're scrolling around. Clicking on that button takes you back to the top of the page.
This is a great feature to have on any website, and today we are going to see how to build it with nothing but HTML, CSS, and JavaScript.
How to Make Vue v-on:click Work on Component
There is a situation when you want to use the on click directive inside a component but it doesn’t work. Here we suggest a snippet that will work like a charm.
To listen to native events on the root element of a component, the .native modifier for v-on should be used like this:
<template>
<div id="app">
<test v-on:click.native="testFunction"></test>
</div>
</template>
There is a shorthand version of the above snippet:
What is the Difference Between the Created and Mounted Hooks in Vue.js
Programmers are still struggling with the created and mounted hooks in Vue.js and trying to find out what is the difference between these two. Let’s figure out together and see which method is used for real-life situations covered up in this tutorial.
How to programmatically login/authenticate a user Symfony
Last night I was experimenting with Silex and I needed a register/login form. Silex comes with a SecurityServiceProvider
which gives you the power of the symfony/security component. But I couldn’t figure out how to programmatically login the user after registration. So here’s my solution:
In order to login you have to do following steps
How to keep symlinks in web/bundles after composer update Symfony
When updating vendor through "composer update" or "composer install", the content of "Resources/public" of each bundle is copied into web/bundles, to create symlinks you have to make a small change in composer.json.
{
"extra": {
"symfony-assets-install":"symlink",
}
}
Create taxonomy term programmatically drupal
We know Taxonomy is a powerful core module and helps us categorize the content. A vocabulary in Drupal is essentially a container for terms that are used by the system. These terms are what Drupal uses to connect certain areas together within the website.
How to Use bcrypt to Hash Passwords in PHP
It is not a secret that storing passwords in a clear text is not secure. However, sometimes developers do that to make the site easy for password recovery. There exists a password hashing technique that is used for building the security of passwords. It is called bcrypt. You can use it for protecting the password from different attacks. With it, the password is kept in a bcrypted format. In this snippet, we will demonstrate the way of using the bcrypt technique for hashing passwords. It can be done with the password_hash() function.