How to remove webform error message?

1 month 2 weeks ago

How to remove webform error message? I need to be able to remove the error message form.

For instance, if I have an email field and for some reason did not pass the validation is not to show a message saying.

The entered e-mail address "djhshsj" does not appear valid.

So my question is how I can remove that Drupal message?

Update 1: I had to render the error message below the button (I could not just move with CSS ). So I ended up doing my custom validation + error message. And even though I have my custom validation, webform still validate if that field is correct or not. However, all I want to do is to remove the message NOT the validation.

itsdarrylnorris

How to alter the welcome message after successfull registration

1 month 2 weeks ago

A message is shown upon successful registration, with the following contents:

A welcome message with further instructions has been sent to your e-mail address

I would like to change the content of that message and use a different HTML structure, e.g.:

<p>Thanks for registering</p> <a href="#">continue</a>

How can I do that?

user59414

Figuring out a conditional statement for a specific page

1 month 2 weeks ago

I have a view which is modified by a views template page - this is in Drupal 6.

I'm trying to figure out a condition to affect the layout. Currently, the element seems to be generated in page.tpl.php, which is fine, but I want to add a condition for this specific page, in order to add an id to this element.

For other pages, I've used the node id to do this, as such:

else if ($node->nid == '250' || $node->nid == '429' || $node->nid == '555' || $node->nid == '378') {print '<h1'. ($tabs ? ' class="with-tabs"' : '') .' id="medspecheader">'. $title .'</h1>';}

But I'm not sure how to do this with the view page. Is there a machine name that I can use, or something to affect the layout?

Jack Ryan

Average value of integer field using views

1 month 2 weeks ago

I set up a multi value cck integer field for rating purposes. It has values

1|good 2|bad 3|dont know

Users voted like so:

3 votes for good 2 votes for bad 4 votes for dont know

I want to make an average from all values. In views 3 I checked grouping and set group type average on cck field inside views. Unfortunately, Instead of 1 result I get 3 results - for every value set in cck field. Results are 1, 2 and 3 which is useless. How it is possible to get only one average number? Thank you

EDIT: the average value works the same way using simple text fields. Views group by in views 3 counts only values that are the same. And it looks like it is known issue http://drupal.org/node/903768

loparr

How can I get translation for a field of custom date

1 month 2 weeks ago

I am using the paragraphs module. I have a field which contains a date and time e.g. for events, which is added by an author. For the output I use a paragraph-twig-file and I have this:

<div class="timeline-date"> {{ content.field_date }} </div>

In the backend of Drupal I created a custom time "D, d.m.Y - H:i". The output is right e.g. "Fri, 24.08.2018 - 17:14", but my site is in german and not english. So how, can I translate the day of week in german? In my case this solution is not working

lesley n.

Alter Registration Form Text

1 month 2 weeks ago

I am trying to alter the email description text on my user registration page. I have added the following to the bottom of my template.php file but nothing is happening. It seems like the function isn't even being called. Any suggestions?

function theme_form_alter(&$form, &$form_state, $form_id){ switch($form_id) { case 'user_register_form': $form['account']['mail']['#description'] = t('E-mail Address'); } }
John

How do I remove JOIN in hook_views_query_alter()?

1 month 2 weeks ago

I have a view with two filters (A + B). Filter B should only be included in the query, if a specific value in filter A is set (like a "conditional filter").

So I tried to remove the where condition of filter B in hook_views_query_alter by unsetting it:

if($remove_filter_B){ foreach ($query->where as $condition_group_key => &$condition_group) { foreach ($condition_group['conditions'] as $condition_key => &$condition) { if($condition['field'] == 'field_B_to_remove'){ unset($condition_group['conditions'][$condition_key]); break; } } } }

I successfuly removed the where clause but the INNER JOIN on the table of filter B is still part of the query. How can I remove it? I've tried unset($query->tableQueue['node__field_B_to_remove']) but this doesn't work because tableQueue is protected.

Maybe I'm going the wrong way. Basicly I just want to have a "conditional filter".

Some aditional info: The view lists nodes of two different types. You can filter those node types with filter A. The field of filter B only exists in one of the node types. So if you choose filter B you only get nodes of one type. And when you select the other one in filter A you get no result. And that's the issue.

Philipp Michael

Count total number votes a user has gained

1 month 2 weeks ago

I am using rate module where users can plus or minus the articles created by an author. Now, in the profile page of the author, I want to display the total number of votes he/she has got from all his articles. Is there any way to do this without using db_query ? Thank you.

Sandesh Yadav

Fielded Relation's Field not showing in Views

1 month 2 weeks ago

I'm trying to implement a "rating" system with Relation module. I have a Relation Type defined from a user --> node. The Relation Type has an Integer field to hold the rating.

I want to produce a view that shows the number of ratings and average rating. To start, I created a view with a list of nodes. I previously created a few "rating" relations between users and the nodes in the view, which can be seen in the Relations tab in content.

In views UI Advanced section, I added the Relationship from the node to its Relation. I added a view field for the Integer field on the Relation.

The label for the rating field shows, but the number is empty, even for relations I know are there.

Here is an export of the view:

$view = new view(); $view->name = 'offer_ratings'; $view->description = ''; $view->tag = 'default'; $view->base_table = 'node'; $view->human_name = 'Offer Ratings'; $view->core = 7; $view->api_version = '3.0'; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ /* Display: Master */ $handler = $view->new_display('default', 'Master', 'default'); $handler->display->display_options['title'] = 'Offer Ratings'; $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'perm'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; $handler->display->display_options['pager']['type'] = 'full'; $handler->display->display_options['pager']['options']['items_per_page'] = '100'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'fields'; /* Relationship: Content: Relation: rated by (node → relation) */ $handler->display->display_options['relationships']['relation_base_right_rated']['id'] = 'relation_base_right_rated'; $handler->display->display_options['relationships']['relation_base_right_rated']['table'] = 'node'; $handler->display->display_options['relationships']['relation_base_right_rated']['field'] = 'relation_base_right_rated'; $handler->display->display_options['relationships']['relation_base_right_rated']['r_index'] = '1'; $handler->display->display_options['relationships']['relation_base_right_rated']['entity_deduplication_right'] = 0; /* Field: Content: Title */ $handler->display->display_options['fields']['title']['id'] = 'title'; $handler->display->display_options['fields']['title']['table'] = 'node'; $handler->display->display_options['fields']['title']['field'] = 'title'; $handler->display->display_options['fields']['title']['label'] = ''; $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; /* Field: Relation: Rating */ $handler->display->display_options['fields']['field_rating']['id'] = 'field_rating'; $handler->display->display_options['fields']['field_rating']['table'] = 'field_data_field_rating'; $handler->display->display_options['fields']['field_rating']['field'] = 'field_rating'; $handler->display->display_options['fields']['field_rating']['relationship'] = 'relation_base_right_rated'; $handler->display->display_options['fields']['field_rating']['settings'] = array( 'thousand_separator' => '', 'prefix_suffix' => 1, ); /* Sort criterion: Content: Post date */ $handler->display->display_options['sorts']['created']['id'] = 'created'; $handler->display->display_options['sorts']['created']['table'] = 'node'; $handler->display->display_options['sorts']['created']['field'] = 'created'; $handler->display->display_options['sorts']['created']['order'] = 'DESC'; /* Filter criterion: Content: Published */ $handler->display->display_options['filters']['status']['id'] = 'status'; $handler->display->display_options['filters']['status']['table'] = 'node'; $handler->display->display_options['filters']['status']['field'] = 'status'; $handler->display->display_options['filters']['status']['value'] = 1; $handler->display->display_options['filters']['status']['group'] = 1; $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; /* Filter criterion: Content: Type */ $handler->display->display_options['filters']['type']['id'] = 'type'; $handler->display->display_options['filters']['type']['table'] = 'node'; $handler->display->display_options['filters']['type']['field'] = 'type'; $handler->display->display_options['filters']['type']['value'] = array( 'offer' => 'offer', ); /* Display: Page */ $handler = $view->new_display('page', 'Page', 'page'); $handler->display->display_options['path'] = 'offer-ratings';
Joe Beuckman

Prevent dual submit on form submission

1 month 2 weeks ago

I've got a form that submits via AJAX and in the callback I need to rebuild certain parts of the page to reflect the newly submitted data. One of these parts is the form, which I need to clear all user input values from so it's ready to use again.

$response = new AjaxResponse(); // Remove all user submitted values $form_state->setValues( array() ); $form_state->setRebuild( TRUE ); // Build a new instance of the form $form_object = \Drupal::service('class_resolver')->getInstanceFromDefinition('Drupal\tpl_project\Form\MultiContactForm'); $form_object->setCompany( $company ); $replacement_form = \Drupal::formBuilder()->buildForm( $form_object, $form_state ); // Replace the old form with the new one $response->addCommand(new HTMLCommand('.form-container', $replacement_form)); return $response;

When the form is submitted it runs the validation callback, the submit handler, then calls the above ajax handler. When it rebuilds the form in the above process, it fires the validation and submit handles again, thus storing two records.

How can I prevent this from happening and still rebuild the form to display no user input all within the same request?

Any help greatly appreciated.

Lyndon Cox

Implementing preprocess function for custom template

1 month 2 weeks ago

In Drupal 7, I'm creating thank you page for a custom form and have following in my mymodule.module:

function mymodule_menu() { $items = array(); $items['mymodule/thank_you/%'] = array( 'title' => 'My Module Thank You Page', 'description' => 'my module thank you page', 'page callback' => 'mymodule_thank_you_page', 'access arguments' => array( 'access mymodule thank you page' ), 'type' => MENU_NORMAL_ITEM, ); return $items; } function mymodule_theme() { return array( 'mymodule_thank_you' => array( 'variables' => array( 'form_id' => NULL, 'content' => NULL, 'title' => NULL, ), 'template' => 'thank-you', 'file' => 'mymodule.theme.inc', 'path' => drupal_get_path('module', 'mymodule') . '/templates', ), ); } function mymodule_thank_you_page() { drupal_set_title( t( 'Thank You.' ) ); $variables = array(); return theme( 'mymodule_thank_you', $variables ); }

In mymodule.theme.inc, I have:

function template_preprocess_mymodule_thank_you( &$variables ) { $variables['title'] = 'test'; }

The problem I'm facing is that while I can access the thank-you template correctly, it doesn't read any of the variables I define in the preprocess function in the theme.inc file. Can anyone advice what I'm doing wrong for this?

Drupal Themer

Exposed filter or facet for a vocabulary listing select list

1 month 2 weeks ago

I have to create a form with a fulltext search field and a dropdown listing every terms of a certain vocabulary. On submission the form is redirecting the user with the value of both the fields as parameters in path. I don't know which should be better to use between a facet or a simple list listing every terms of the needed vocabulary?

jzucco

How to filter GraphQL query by content language?

1 month 2 weeks ago

I am coding Drupal 8/Angular app and Angular is fetching data from Drupal using GraphQL. Everything works fine except now I need to query nodes in a particular language. This is my query:

{ nodeQuery(filter: {conditions: [ {field: "type", value: "akcia", operator: EQUAL, language: EN}, {field: "field_datum", value: "2018-02-12T18:00:00", operator: GREATER_THAN_OR_EQUAL} {field: "langcode", value: "en", operator: EQUAL} ]} sort: {field: "field_datum", direction: DESC} ) { entities { entityLanguage { id } ... on NodeAkcia { nid langcode { value } title fieldDatum { value } body { value } fieldObrazok { url } path { alias pid langcode pathauto } } } } }``` Notice the `{field: "langcode", value: "en", operator: EQUAL}` line - that's the best thing I came up with, however, the query returns Slovak version of that node, not the English one. Is there any better way ho to filter nodes based on their translation?
petiar

Fatal error: Call to undefined function system_run_automated_cron()

1 month 2 weeks ago

I migrated my database from oracle to mysql and when linking it to my drupal the following error:

Fatal error: Call to undefined function system_run_automated_cron() in /var/www/drupal/includes/common.inc on line 2732 Call Stack # Time Memory Function Location 1 0.0000 241712 {main}( ) .../index.php:0 2 0.1117 1842704 menu_execute_active_handler( ) .../index.php:21 3 0.1120 1844088 drupal_deliver_page( ) .../menu.inc:532 4 0.1123 1845064 drupal_deliver_html_page( ) .../common.inc:2589 5 0.1213 1858496 drupal_page_footer( ) .../common.inc:2705

Someone could help me solve this problem?

rpayanm

How to configure a custom POST api to accept a request with Content-Type as "application/x-www-form-urlencoded" in the header?

1 month 2 weeks ago

I created a controller in a custom module that accepts a POST request.
I have a setup such that I get a POST request from a third-party application server to this API. But the POST request has a Content-Type: "application/x-www-form-urlencoded" in the header.
And because of this I get the following error in the recent log messages:

Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException: No route found that matches "Content-Type: application/x-www-form-urlencoded" in Drupal\Core\Routing\ContentTypeHeaderMatcher->filter() (line 49 of /var/www/html/web/core/lib/Drupal/Core/Routing/ContentTypeHeaderMatcher.php).```

When I test the API using postman:

  1. if I use the Content-Type: "application/json" in the header, the code inside the API is executed, and I get the correct response.
  2. if I use the Content-Type: "application/x-www-form-urlencoded", I get the same error.

I cannot configure the third party application server to change the Content-Type. So the only option for me is to configure the API to accept the POST request with the Content-Type: "application/x-www-form-urlencoded". How can I do that?

Edited: My class extends the class ResourceBase. Route definition of the controller. Also I am using drupal 8.

* @RestResource( * id = "test_abc_callback", * label = @Translation("Custom API for Test"), * uri_paths = { * "create" = "/api/v1/test_callback", * } * )
Kiran Dhakal

Programmatically format integer field display

1 month 2 weeks ago

I am trying to programmatically format how an integer field displays. So far I have only been able to produce "1.00", and I am trying to get it like so: x.xx.x. The content type is "Project" and the field is "Drupal version".

Here is my code:

<!-- Display the drupal version with decimals --> <?php if (isset($node) && $node->type == 'project'): ?> <?php $drupal_version = field_view_field('node', $node, 'field_drupal_version', array('label'=>'default')); ?> <?php $formatted_drupal_version = number_format((float)$drupal_version, 2); ?> <?php echo "Drupal version: " . render($formatted_drupal_version); ?></span> <?php endif; ?>

output: Drupal version: 1.00

Does anyone know why this is the output, and how I can extend this function number_format to produce something in this format x.xx.x, for example "Drupal version: 7.41.1" ?

Thanks!

Jill

How to create a message when comment is voted?

1 month 2 weeks ago

I created a custom module to work with the message stack and votingapi. My goal is to send a notification to the author when an entity is voted.

When the node is voted the notification goes to the node author successfully. But unfortunately the same thing does not work for comment author.

When a comment is voted, a notification is sent to another member(uid) instead of the comment author. What am I missing? Thanks...

<?php /** * @file * Primary module hooks for Jasy custom module. */ use Drupal\comment\Entity\Comment; use Drupal\Core\Entity\ContentEntityBase; use Drupal\message\Entity\Message; use Drupal\message_subscribe\Subscribers\DeliveryCandidate; use Drupal\node\Entity\Node; use Drupal\user\Entity\User; use Drupal\votingapi\Entity\Vote; /** * Implements hook_vote_insert(). */ function jasy_custom_module_vote_insert(Vote $vote) { $notifier = \Drupal::service('message_notify.sender'); // Create a message for the node author. if ($vote->getVotedEntityType() == 'node') { $node = $vote->get('entity_id')->first()->get('entity')->getTarget()->getValue(); $message = Message::create(['template' => 'node_owner_vote_notification', 'uid' => $node->getOwnerId()]); $message->set('field_node_reference', $node); $message->set('field_published', $node->isPublished()); $message->set('field_vote_reference', $vote); $message->save(); // Immediately notify message creator (node author) about new vote. $notifier->send($message, [], 'email'); } // Create a message for the comment author. if ($vote->getVotedEntityType() == 'comment') { $comment = $vote->get('entity_id')->first()->get('entity')->getTarget()->getValue(); $message = Message::create(['template' => 'comment_owner_vote_notification', 'uid' => $comment->getOwnerId()]); $message->set('field_comment_reference', $comment); $message->set('field_published', $comment->isPublished()); $message->set('field_vote_reference', $vote); $message->save(); // Immediately notify message creator (comment author) about new vote. $notifier->send($message, [], 'email'); } } /** * Set message entity published field when it changes in the related entity. * * @param \Drupal\Core\Entity\ContentEntityBase $entity * The entity object. */ function jasy_custom_module_update_message_status(ContentEntityBase $entity) { if (!empty($entity->original) && $entity->isPublished() == $entity->original->isPublished()) { return; } $query = \Drupal::entityQuery('message'); $field = 'field_' . $entity->getEntityType()->id() . '_reference'; $query->condition($field . '.target_id', $entity->id()); $results = $query->execute(); if (empty($results)) { return; } $messages = Message::loadMultiple($results); foreach ($messages as $message) { $message->set('field_published', $entity->isPublished()); $message->save(); } }
jay
Checked
10 hours 42 minutes ago
most recent 30 from drupal.stackexchange.com
Subscribe to Drupal StackExchange feed