Blog

If you have already created a webform then you can follow thi step 1. Open this url /admin/structure/webform (Structure -> Webform) 2. Click on "Build" in OPERATIONS column 3. Click on "+Add element" button, there will be seen a list form element 4. You can select Captcha from available list.
Set current date in custom form element in DRUPAL8 Add this line at top use Drupal\Core\Datetime\DrupalDateTime; function HOOK_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($form_id == 'node_article_form') { $form['field_date']['widget'] = array( '#type' => 'datetime', '#title' => 'Enter Date', '#required' =>...
Method to redirect on node id url $url = Url::fromRoute('entity.node.canonical', ['node' => $nid]); $form_state->setRedirectUrl($url); Method to redirect on custom url $url = Url::fromRoute('olsys.mycustom_dashboard'); $form_state->setRedirectUrl($url); Redirect on user view page of loggedin user use Drupal\Core\Controller\ControllerBase; // Use this on top return $this->...
Code to query for getting node according to field condition in DRUPAL 8 $query = \Drupal::entityQuery('node') ->condition('status', NODE_PUBLISHED) ->condition('type', 'custom_type'); $and = $query->andConditionGroup(); $and->condition('custom_taxonomy', 2); $query->condition($and); $and = $query->andConditionGroup(); $and->condition('custom_taxonomy', 8); $...
We can get value at node.html.twig for the following feild type using these given method. Field Type Body Text List Image File Boolean Number Email Phone Date Taxonomy/Entity Reference Labels for any field type Multi-value for any field type I use the word ‘display’. When I’m talking about the more raw version of the content, I use ‘value’. 01. Body The default body field on a content type is...
$language = \Drupal::languageManager()->getCurrentLanguage()->getId(); $user = \Drupal\user\Entity\User::create(); // Mandatory. $user->setPassword('password'); $user->enforceIsNew(); $user->setEmail('email'); $user->setUsername('user_name'); // Optional. $user->set('init', 'email'); $user->set('langcode', $language); $user->set('preferred_langcode', $...
When we apply coupon for discount its applied for sale price by default but we need to apply discount coupon on regular price so you can use this code on function.php By default cart and product show sale price after applying this code Regular price will be update on cart. add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 10, 1); function add_custom_price( $cart_object...
Soln. 1. Install Ludwig module https://www.drupal.org/project/ludwig,  2. Download library from https://github.com/commerceguys/addressing  3. Extract folder and replace folder name as v1.0.0 4. place the library folder (v1.0.0) in modules/address/lib/commerceguys-addressing 5. You can check library status at /admin/reports/packages (Ludwig module show status and suggesstion of...
If you want to add if condition in my "global custom text" field in views Drupal 8 Example 1: Check node status and put conditional link according to publish status {% if status %} put your HTML as condition {% endif %} Example 2: In this example we are checking a field value is empty or not. according to value in we are showing link or status {% if field_final_layout_date...
I want to change select list value in my state field so we follow the step My content type is 'project' so we can get the form id as 'node_project_form' I have a feild 'state' in my content type so field machine name is 'field_state' function MODULENAME_form_alter(&$form, FormStateInterface $form_state, $form_id) { $dropdown_array = array('DL'=>'Delhi'); if ($form_id == '...

Pages