Drupal StackExchange

How to set Panel to homepage when setting the panel's path as homepage on Configuration > Site Information doesn't work?

1 month 3 weeks ago

I have created a panel for my home page and set its path to /home. I have changed the directory of the front page in Admin > Configuration > Site Information to mysite.com/home. Still, when I visit mysite.com/home, the custom panel saved to path /home doesn't populate.

I've made sure I'm saving correctly (rather than just updating) and have also cleared my cache.

Any ideas how else I might be able to fix?

Thanks in advance!

user2865430

How do I output XML schema?

1 month 3 weeks ago

I have set the REST server with the Services module.

Also I've installed the Services Views module, created a new view that outputs the desired fields into XML.

That's working fine.

How can I add XML schema to that output, so the XML will look like:

<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> .....
user2519032

Modifying a custom form on submit

1 month 3 weeks ago

I have a custom module with a custom form, Drupal 10, and when the form is submitted I want to either 1. add some markup to the submitted page or 2. change a value on the form. I have failed on the former, so I am trying the latter.

Here's my code, without the chaffe:

public function buildForm(array $form, FormStateInterface $form_state): array { $form['plate'] = [ '#type' => 'textfield', '#title' => $this->t('Plate'), ]; $form['actions'] = [ '#type' => 'action', 'submit' => [ '#type' => 'submit', '#value' => $this->t('Search'), ], ]; } public function submitForm(array &$form, FormStateInterface $form_state): void { $this->messenger()->addStatus($this->t('The form has changed')); $form_state->setValue('plate', 'Changed Value'); $form_state->plate = [ '#type' => 'textfield', '#title' => $this->t('Plate wjiijowqoiwefewiofjewfio'), '#value' => 'Changed Value', '#default_value' => 'Changed Value', ]; $form_state->plate['#value'] = "Changed Value"; $form_state->setRebuild(); }

Can you see where I am going wrong?

Banners

theme contact form block

1 month 3 weeks ago

I am using contact_form_blocks-7.x-1.x-dev module. Using this module I have embedd contact us form in my website. For themeing I have created file named block--contact.tpl.php. Cleared cache, but it doesnt result anything.
How should I theme this contact us form?

Yogesh

Webform email handler - dynamic recipient list

1 month 3 weeks ago

Our site uses webforms and for a particular form - upon submission - an email is sent to multiple people. Currently, that recipient list is part of 'config' - meaning that to add/delete someone is a config change and since we are using best practice of configuration as code - this means pushing a new release. I am looking for a way to create the recipient list dynamically - say based on a user attribute - so that a site admin/editor could modify it and not require a code push.

jwag

What is the correct order of disabling the default contact form on Drupal?

1 month 3 weeks ago

Drupal comes with a default contact form on each site we install. And while we already have the webforms and recaptcha module installed, some of our site owners still use the default contact form found in /admin/structure/contact.

I need to remove them because when they are enabled, the site is prone to spam attacks. I've had a few instances where some of the sites had form submissions with PDF file uploads of inappropriate content. So you see how this is a security risk for our organization.

I removed that contact form in my local site by disabling the following modules in this order:

  • contact form
  • contact storage
  • contact

But I need to do this for all our sites now, so I wrote the following in my hook_update_n() function:

function my_profile_update_8011() { $config = \Drupal::configFactory(); $moduleHandler = \Drupal::service('module_handler'); if($moduleHandler->moduleExists('lightning_contact_form')) { Drupal::service('module_installer')->uninstall(['lightning_contact_form']); } if($moduleHandler->moduleExists('contact_storage')) { Drupal::service('module_installer')->uninstall(['contact_storage']); } if($moduleHandler->moduleExists('contact')) { Drupal::service('module_installer')->uninstall(['contact']); } }

When I deployed this update to our dev environment, it would work on most of the sites, but fail on the rest. They all have this same error message:

The error output from the server was: > [notice] Update started: my_profile_update_8011 > [error] SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause': SELECT 1 AS expression > FROM > {contact_message} t > WHERE id IS NOT NULL > LIMIT 1 OFFSET 0; Array > ( > ) > > [error] Update failed: my_profile_update_8011 [error] Update aborted by: my_profile_update_8011 [error] Finished performing updates.

All our sites share the same codebase, so I don't know where my update hook went wrong. Is there a better way of disabling these modules?

thanks, Kevin

kcsting

How do I use an absolute URL to set as breadcrumb link?

1 month 3 weeks ago

I would like to use absolute URL instead of relative URL as the breadcrumb link on my website. Right now, I am using Drupal 7 and Path Breadcrumb 7.x-3.0 Module. All my breadcrumbs are set by Module.

This is a sample of my breadcrumb right now.

<div id="breadcrumbs"> <h2 class="element-invisible">You are here</h2> <div class="breadcrumb"> <a href="/">Home</a> » <a href="/category.html">Category</a> </div> <span class="delimiter"> &gt; </span> <strong>Dimmer</strong> </div>

How can I make the breadcrumbs like these?

<div id="breadcrumbs"> <h2 class="element-invisible">You are here</h2> <div class="breadcrumb"> <a href="http://mywebsite.com">Home</a> » <a href="http://mywebsite.com/category.html">Category</a> </div> <span class="delimiter"> &gt; </span> <strong>Dimmer</strong> </div>

EDIT

My breadcrumb code is generated by print $breadcrumb; in the page.tpl.php file. How can I convert the breadcrumb link from Relative to Absolute in this case?

jmu

How do I add the "error" class when a form validation fails?

1 month 3 weeks ago

I'm working with Drupal 7.56 and I am using the Webform module to create a custom form.

I used hook_form_alter() in a custom module to add a validation test.

function mymodule_form_alter(&$form, &$form_state, $form_id) { if ($form_id=='webform_client_form_1') { $form['#validate'][]='mymodule_form_validate'; return $form; } } function mymodule_form_validate($form, &$form_state) { $aux = $form_state['values']['submitted']['aux']; if ($aux != '') { if( /* my test */ ) { $text = t('Please check your input'); form_set_error('aux', $text); } } }

How can I add the error class when my test fails?

A.Sana

Use hook form alter to change input type

1 month 3 weeks ago

I am trying to change the input type on an ubercart checkout form using hook_form_alter. I added an extra field using the uc cart extra fields pane module but there is no option to add e-mail - only text - and I need the field I added to validate as an e-mail.

The field in question is:

<input type="text" id="edit-panes-billing-address-billing-ucxf-bill-to-email" name="panes[billing][address][billing_ucxf_bill_to_email]" value="" size="32" maxlength="255" class="form-text required">

The code I am using but with no success is:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'uc-cart-checkout-form') { form['panes-billing-address-billing-ucxf-bill-to-email'][LANGUAGE_NONE][0]['type'] = 'email'; }

Thanks for any assistance!

penone