Suranga Panagamuwa Gamage
  • Member for 7 years, 1 month
  • Last seen more than 3 years ago
Display a view inside a <nav> and <ul>
Accepted answer
3 votes

A tutorial with more detail can be found here tutorial. But in short what you want to do is the following: Find the correct .tpl file and copy it into your theme. Edit the .tpl in your theme and ...

View answer
How to programmatically create Fields?
3 votes

In your install file you'll need to define both the 'hook_install' and the 'hook_uninstall'. Example included but read all about the extra keys in the API references (code is untested so might be typo'...

View answer
Submit not executed
2 votes

Forms need to be called via drupal_get_form() that processes your $form array into a form. Including the submit handling. So it should look like more like this: /** * Implements hook_menu(). */ ...

View answer
How can i add a span element within the search form using hook_form_alter?
Accepted answer
2 votes

For the placeholder just add this line to the hook_form_alter $form['FIELD_I_WANT_TO_ALTER']['#attributes']['placeholder'] = 'placeholder text'; The span can be done in a few ways but the shortest ...

View answer
Join two tables (users and userpoints_total)
1 votes

You don't call a result set method on your query. Try $results = $query->execute()->fetchAll(); and have a look at the results via devel or something similar. I believe that block['content'] ...

View answer
Using ajax in my entityform
1 votes

The ajax from a form is handled by the form function itself wich is edited in the mdule layer, not in the template layer. The custom module approach would be. Find the id of the entity form, see ...

View answer
Is there a best form for security surrounding updating an entity of an unspecified type?
1 votes

I think the entity metadata wrapper is semi indiscriminate aslong as the field is the exactly the same on both entities. So you can just wrap it and then use the default set/get methods // All your ...

View answer
Get Div's Text in Drupal Forms API
1 votes

If you want to pass values you should just use one of the form api form elements. Doing something similar to this // This shows a preview to the user but doesn't actually pass any values. $form['...

View answer
Create a secondary form to fill data into an entity
Accepted answer
1 votes

I don't know about the webform solution/Redhen but programmatically/basic drupal speaking I would just use HOOK_form_FORM_ID_alter to restrict access to certain form elements based on role/...

View answer
How do I conditionally style an image field based on terms
0 votes

Simplest way is to add/edit the node--article.tpl.php (don't forget to flush caches after you have). Once you have done this you can vary the output based on the values in the $node object. Node ...

View answer
How do you load a select field with pre-selected items when the Chosen module is installed/enabled?
0 votes

Your select field is currently only accepting one selected option. This is why it won't allow an array as a default value. (It expects a string or an integer). The following select field allows more ...

View answer
Showing local tasks in toolbar with hook_toolbar: caching problem
0 votes

"The toolbar is a container for administrative and site-global interactive components." https://api.drupal.org/api/drupal/core!modules!toolbar!toolbar.api.php/function/hook_toolbar/8.2.x That would ...

View answer
How can one add inline JavaScript in the validation function for the Form API?
0 votes

Use the #attached property to add your JS file instead of drupal_add_js function More info: FAPI #attached

View answer
Completing commerce order triggering other modules rules checkout complete
0 votes

Axscode's answer will probably work (untested but I believe in you axscode ;) ) But to eleborate. Like alter hooks, rules events are called via code. Possibly after all hooks have finished running (...

View answer
How to rearrange user register form and still pass validation
0 votes

I would try defining the name of the field manually like so. This should overwrite the default naming of the variable in the values/input array in the $form_state. $form['profile_supplier']['account'...

View answer
Redirecting doesn't work with a custom form in a block
0 votes

I believe the redirect should be $form_state['redirect']

View answer
db_query or db_select for getting content type fields
0 votes

$result = db_query('SELECT field_1, field_2 FROM table_name WHERE bundle = :bundle AND entity_type = :entity_type', array(':bundle' => 'page', ':entity_type' => 'node' )->fetchAll(); Will ...

View answer
How can i include views page in search results
0 votes

Building a page via the views interface implements this page with the hook_menu. An entirely different approach from the nodes wich are saved in the database. Views is essentially a query engine ...

View answer
How to uninstall MailChimp
Accepted answer
0 votes

Are you sure you got all the module files? Normally they are placed in 'sites/all/modules' not 'sites/all' perhaps this was only the mailchimp library? But that should have been in 'sites/all/...

View answer
Drupal Form in Block will NOT call Submit or Validate handlers
0 votes

Those are the only 3 differences I can see between (working) block forms I have written in the past and your code. 1) What are the exit(); lines there for? Maybe try removing those? 2) I usually ...

View answer
How to create form on users account page?
Accepted answer
0 votes

You'll have to define a form function using the drupal form API See this tutorial for more info on how to make your own forms. So the actual form function would look something like this ...

View answer
How to not let users remove the entity reference once they added
0 votes

Using Hook_form_FORM_ID_alter on the node form and disabling the field for users that are not the initial author should work. Code is untested but shows the general idea behind the solution ...

View answer
How to make labels of fields selectable?
0 votes

You'll have to make a custom field formatter with a settings form where you select the label and then output it accordingly. Like in this tutorial about field formatters

View answer
Embed form within a form
Accepted answer
0 votes

Nesting forms in other forms is not valid in html. see this post html nesting forms in forms You can always try calling the form directly via the actual form function instead of via drupal_get_form ...

View answer
Access values from multiple field forms as elements of one form
Accepted answer
0 votes

You need to use the #parents variable as documented in the field_attach_form page. See field_attach_form

View answer
User profile private public toggle
0 votes

Easiest way would be to change the access callback to the user page (user/%user) via hook_menu_alter. The new access callback would use the value of a user field to determine or the page is ...

View answer
Add to cart form AJAX not working when loading a product display via AJAX
0 votes

The reason why it redirects after adding to cart is because the add to cart form doesn't use ajax by default. Wich causes it to redirect the user when submitted. If you want it to use ajax you'll ...

View answer
How can I get a default value in a dropdown using form API?
0 votes

For required items a -select- item is added automatically. If the form field is not a required one, you'll have to add it manually, for example with the following code. $options = array('_none' =&...

View answer
breadcrumb containing a link to a path that's deeper than the one of the page it's on
Accepted answer
0 votes

Is it possible that there is an old link to this page in your menu that is nested in the tree like. home -page --MY-PAGE Because breadcrumbs seem to use the menu tree to build the breadcrumb items.

View answer
Print specific field of a specific node
-1 votes

If you're not familiar with the module layer of drupal I would suggest using the views module to build a view page of all the nodes of type "Front Page Section" and use this as the front page. https:/...

View answer