Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

0

Instead of unsetting the #value property (which works, but I find it personally counter-intuitive), you could try setting it using the form_type_image_button_value() function. function my_custom_module_form_views_form_commerce_cart_form_default_alter(&$form, &$form_state, $form_id) { if (!empty($form['edit_delete'])) { foreach(element_children(...


1

You need to unset the #value on your image_buttons: $item['#type']='image_button'; $item['#src']='sites/all/themes/mytheme/images/trash.svg'; $item['#alt']='Remove'; unset($item['#value']); // this line here The line item that is deleted is determined by the #triggering_element in your $form_data. This element is determined by a function ...


1

As suggested in the comment the SQl query were made on the hook_form and the hook_form_submit contains only the $form_state['rebuild'] = TRUE;. Detailed code is as follows: function form_example_form($form, &$form_state) { //your form fields or items $form['submit_button'] = array( '#type' => 'submit', '#prefix' => '<div class="button-...


0

It's the expected behavior, and it's described in the documentation for hook_menu(), even it could not be clear, at a quick read. Callback Functions The definition for each path may include a page callback function, which is invoked when the registered path is requested. If there is no other registered path that fits the requested path better, ...


0

In a clean Drupal 8 way, you could alter tasks by using modulename_local_tasks_alter(), as described in the documentation /** * Implements hook_local_tasks_alter(). */ function modulename_local_tasks_alter(&$local_tasks) { // Remove unwanted tabs // Here, we'll remove the "Payment method" tasks from the user edit tasks unset($local_tasks['entity....


0

I just had this issue, and thought I'd add to the pile since I can't see it mentioned in other answers. My issue was with Drupal 8.7 and the issue was the module name had uppercase characters which caused it to fail any checks for updates. For example: myModule. The reason is drupal_get_schema_versions() has a static array of $updates which is an ...


0

I have found an answer. I am sharing it here so that it can help someone. Instead of form_alter hook, we can use hook_views_pre_view. Here is the code /** * Implements hook_views_pre_view(). */ function mymodule_views_pre_view(&$view, &$display_id, &$args) { if ($view->name == 'my_view_name') { $address = 'some address'; $...


0

I think this can be done with Drupal 8 and VBO (at least it worked for me) - using the "Modify field values" action - because "Generate automatic URL alias" is just a field automatically provided for each item of content. The caveat is that you'll have to do it for each content type, but this can all be done on the same form as follows :- Select the items ...


0

I am sure the answer provided by kiamlaluno is correct, and I don't know why it doesn't work for me. Maybe it does work and another commerce module change the value back again, but in case anyone else is struggling with similar problems I would like to share a very simple workaround. The payment method form is created with the hook ...


1

Using google geocoding with geocoder module, you may use another geocoding provider, i think this requires a google map token now given google's new rules : // @return Geometry Returns a geoPHP geometry object. Generally a Point. $point = geocoder('google', $address); $lat = $point->coords[1]; $lon = $point->coords[0]; I did this long time ago, ...


1

token_find_with_prefix() doesn't return, in your case, the [commerce-order:payment-method] token, but tokens like [commerce-order:payment-method:date] or [commerce-order:payment-method:client], if they exist. The correct code you should use is the following one. function mymodule_tokens_alter(array &$replacements, array $context) { if ($context['type'...


1

I don't think you've thought this through. The standard login page (/user/login) only shows the login form when a user is not yet logged in. So if you want the ability for admin users to see the usual options on that page, you will need to show them to all users -- since you don't know whether or not the user is an admin before they log in. If a user is ...


0

You should install module 'currency', add a field of type Entity reference, and choose the 'currency' as the referred type.


0

For any latecomers to this question, there's a module that does just this Views Row Insert It has it's limitations when you start to push it, but it would do just as OP requests with very minimal effort and no hooks needed.


2

After much struggle and enduring endless pain, the solution has been found. The error was all due to the memcache_admin module, which I had to disable in order for anything to work... I ran drush dis memcache_admin and then my entire site worked as expected....


0

Some possible solutions / debugging steps: Check that your local settings.php file is correct by using drush status command. Do this when in the same directory as the settings.php file (or with a correctly set up site alias). You should see information about the database and drupal version. If you don't then something is wrong with your settings. Next, ...


0

I found this Drupal OAuth Server module to be very useful as it allowed me to integrate with many OAuth Clients very easily


0

The Views Sort By Options Weight module allows to do this but for Drupal 8.


0

Depending on your view filters, you might need the patch at https://www.drupal.org/node/1766338


0

You need to patch the contrib module. Patch here works for me.


0

First, check if you have installed the panels_page_cache module. If so, you should go to the panel edition and delete the cache as shown in the image.


1

Drupal can be configured to use a different database for some of the tables. For example, with the following database settings, I would tell Drupal to use the db2 database for the users table. $databases['default']['default'] = array( 'driver' => 'mysql', 'database' => 'db1', 'username' => 'username', 'password' => 'password', 'host' =&...


0

I ended up achieving this. The exposed filter was defaulting to a textbox instead of a select list, so I used hook_form_alter to change it to a select list, and since I was already altering the form I used that time to use EntityFieldQuery to pull in only the 'options' available to the user (based on the assigned_user entityreference field on the district ...


1

Change owner is an action implemented by the Views Bulk Operations module, while Change the author of content is an action implemented by the Node module. (See views_bulk_operations_change_owner_action_info() and node_action_info().) The VBO module implements that action for any entity for which that action makes sense. (In other words, if the entity doesn'...


2

If the district is a term, entity reference, or a list field value, then you should be able to do this. Otherwise, You'll need to do something more involved (and honestly, at that point, you're probably better off just restructuring that data to work with views. As far as only exposing options that will provide valid results, I'd recommend taking a look at ...


0

I've found that jQuery can be used to click a Drupal submit button (source). I can use an event listener to trigger a submit event by interacting with a specific button that can be hidden anywhere on the form. Below is my solution based off of my original demo code. <?php function test_form($form, &$form_state) { drupal_add_js(' (function ($) { ...


0

Edit your Contextual filter and you'll see the option to override the title in the section for when the filter argument is present or a default is provided. You can use tokens from the Replacement patterns section to construct the title text. Your "menu" is likely also coming from the Contextual filter, set to the "Summary" option. Another way is to add ...


0

I solved this, just in case anybody else comes across it. Drupal uses a variable called $op == "Update", which is an attribute on the Submit . When you use preventDefault() this is removed from the Form Data. The solution is to add this to the sweetalert callback function when they confirm to delete or whatever your use case is. formE.off('...


0

I think there is no way to remove it from the BO: You can use code to remove it something like: /** * Implements hook_preprocess_HOOK(). */ function myTheme_preprocess_page(&$variables) { if($variables['is_front']){ drupal_set_title(''); } }


0

You can override the required = true in file_field_instance_settings_form function that returns and form array and then remove the extensions from your ui config so that drupal use with out the validate function that also checks the resource suffixes. Same for Drupal 8. e.g. use Drupal\Core\Form\FormStateInterface; /** * Implements ...


0

Create a custom module and use this code. Make sure to comment out kpr() functions ... they are only here to help inspect what blocks appear and conditions in the current node. function mymodule_block_list_alter(&$blocks) { foreach($blocks as $bid){ kpr($bid); // Enable module Devel - identify the block you want to remove switch ($bid->...


Top 50 recent answers are included