BLOG

Check Form type in Drupal

Sometime you have to add condition on the basis on form type, either it is node type form or taxonomy type form.

But question is how you get the type of the form.

In Your form alter you can find form type. Here is the sample code from my module file.

if($form['#entity_type'] == 'node' || $form['#entity_type'] == 'taxonomy_term') { //when type of form is node or taxonomy
$form['actions']['submit']['#access'] = FALSE; // remove submit button from form.
}

Remove delete and save button from node on the basis of permission

Recently i was assigned to do this task.

What i have done:

1. Created a permission for required role.

2. Checked permission for current user.

3. If user does not have the specific permission disable delete and save button. Here is the code to check the permission and disable edit and save button.

Being a Drupal 8 Acquia certified developer

Finally i got the time to write about my recent certification on drupal 8.

I have been working on drupal 8 from last past year and half. I just got 83 % in this exam.

 I treated this as a proper exam just like a college exam.

You can never clear if you haven't ever worked on drupal

Study material for drupal 8 exam:

  • Here is the weightage of exam.

 

Attach css and js on specific templates in drupal 8

Want to load some specific js and css on particular twig template of drupal 8 ?

Don't worry, you are on the right page.

How to do it :

1. Go to your theme_name.libraries.yml file create a new library in this file for example post the following code:

test-library:
  version: VERSION
  js: 
     https://maps.googleapis.com/maps/api/js?sensor=false: { type: external, minified: true }
     /libraries/jquery.auto-complete.min.js: {}
    

2. Now got to your template(twig template) and paste following code at starting of file:

Pages

Subscribe to RSS - blogs