Drupal 7 - privatemsg module - autocomplete customisation - drupal

I have a privatemsg module in Drupal 7, which uses autocomplete in field "To" (Do is polish translation). It looks very unattractive and I see no option to customise it unfortunately! I checked the code and I tried to modify it, but it doesn't work :o
<input type="text" id="edit-recipient" name="recipient" value="" size="50" maxlength="128" class="form-text required form-autocomplete" />
<input type="hidden" id="edit-recipient-autocomplete" value="http://niemiecki.dogadajsie.pl/messages/autocomplete" disabled="disabled" class="autocomplete" />
As we can see the autocomplete has id="edit-recipient-autocomplete" and class="autocomplete". When I modify it, it just doesn't work in any way. When I tried to search for reference to this id or class I found nothing. Can somebody tell me how to customise it?
Actually it looks like this:
http://i.stack.imgur.com/r6Gej.png
Kind regards, Michael.

What you are trying to modify with the field? You can use hook_form_alter to modify the field. The auto complete class is added because its explicitly set for auto complete.

Related

Using React-hook-form and I can't change the value of posts whether it is published or not

Now, I am working on the project creating a blog like site and I am facing the problem that I can't change the value whether it is published by using checkbox and react-hook-form.
It workded a weeks ago so I am thinking this is due to the update of react-hook-form but I don't know how to solve it.
I am assuming that the code below is the part to be changed.
publish is a checkbox and when checked and submitted the value of post changed to published and turned to be visible. but corrently I can't turn it to be published. It stays false which means it is not published even if it's checked.
<fieldset>
<input className={styles.checkbox} name="published" type="checkbox" ref={register} />
<label>Published</label>
</fieldset>
<button type="submit" className="btn-green" disabled={!isDirty || !isValid}>
Save Changes
</button>
this part works fine.
{!isDirty || !isValid}
I hope some kind people will help me.
Thank you.
The problem here is similar to your last question - you need to modify the usage of register to support v7:
<fieldset>
<input type="checkbox" {...register("published")} />
<label>Published</label>
</fieldset>

Vue.js: insert value into textfield but don't bind it

I am facing an interesting problem: I have a form where I want to insert old values (if the form was submitted before) like this:
<input type="text" :value="oldName" id="name" />
Now the problem is that I can't overwrite the oldName variable like this, so yes, I have the old value in there, but I can't change it anymore. Can you think of a solution? I basically want the value to be in the textfield, but I want the user to be able to change it. Thank you!
Sounds like adding v-once to the input field would solve your problem. V-once means that oldName will be used to render the value once, but after that it will be a normal string literal.
<input type="text" :value="oldName" id="name" v-once/>
In case you want the user to be able to modify the value use v-model instead of v-bind. V-model provides two way binding so when the user writes something in the input field it is reflected in the value.
<input type="text" v-model="oldName" id="name" v-once/>

How to add my CSS class to form in drupal 7

I newbie in drupal 7. I am writing new theme and I don't know how to add my class to form in drupal 7. I install ubercart to setup e-commerce website. I added new attribute for product (Size). I want to redesign in product page. In this page, It has size field but I don't know how to add my CSS. E.g:
<form action="/drupal-7.34/node/6" method="post" id="uc-product-add-to-cart-form-6" accept-charset="UTF-8"><div><div id="uc_product_add_to_cart_form-6-attributes" class="attributes"><div class="attribute attribute-1 odd"><div class="form-item form-type-select form-item-attributes-1">
<label for="edit-attributes-1">Size <span class="form-required" title="This field is required.">*</span></label>
<select id="edit-attributes-1" name="attributes[1]" class="form-select required"><option value="" selected="selected">- Select -</option><option value="1">39</option><option value="2">40</option><option value="3">41</option></select>
</div>
</div></div><input type="hidden" name="qty" value="1">
<input type="hidden" name="form_build_id" value="form-w06CKx7aNBiYShqfg8LiP98CaFLpEb8mgWzFYQWqnQ4">
<input type="hidden" name="form_token" value="JtZIrcKeIfXiVpwX43K6KqHPlZazR1klS1ht3W7PI9I">
<input type="hidden" name="form_id" value="uc_product_add_to_cart_form_6">
<div class="form-actions form-wrapper" id="edit-actions"><input class="node-add-to-cart form-submit" type="submit" id="edit-submit-6" name="op" value="Add to cart"></div></div></form>
I want to add my class to the select element. How can I do that?
In your theme directory there is file named theme_name.info . Inside of it there should be (or you can create it) array that defines css file which will be included on page. Check out explanation here:
https://www.drupal.org/node/171205
https://www.drupal.org/node/171209
So, you basically have to add path of your css file to that list and it will be included on every site page. Your html.php template must print out stylesheets variable (which will contain paths to css files). If you are not sure how to do it check how it's done on some standard drupal theme that comes with drupal installation.
After adding your css to theme info file don't forget to clear the cache!
Other way would be to include it manually, from page.tpl.php file. Just add there common CSS include line, like you would that in plain HTML file.
You can add CSS even from code with drupal_add_css() function, but that's a bit more advanced.
And you can use form id attribute to "aim" it and all inner elements with css.

Request.Form is nothing when the object is disabled

I Google and search every article here and in the google but i cannot find anything regarding this issue. Any idea why the request.form["name here"] is nothing when the html control is disabled something like
<input type="radio" name="name here" disabled />
removing disabled would return the values. I tested this only on IE 10 not sure on other browsers.
I am looking into changing the css of the radio button but that is a different story.
Thank you.
Disabled form fields are not part of the posted data. If you disable the html control the data will not be posted.
If you want to show the data and have it posted, but not possible to edit you can set the control to readonly instead.
<input type="radio" name="name here" readonly="readonly" />

Drupal path problem - views vs node

I've got a problem with my site search not linking properly to my views pages. I've got a views page set up to display recipe data. It has the URL properties of:
index.php?q=recipe/%1/%2
where %1 is the recipe category, for example, breakfast, and %2 is the recipe name, for example, Muffin. The view goes through the recipe node content, and display it as appropriate. The problem is that the site search module doesn't link to the view, it links to the node which still can look like:
index.php?q=node/22
If I edit that node with an URL alias I can turn it into say:
index.php?q=recipe/muffin
But: this clashes with the view display on the site and the search function takes them to the NODE and not to the VIEW. I really, really need them to be taken to the view.
Is that clear?
How can it be fixed?
Edit: the view has variables for both recipe category and recipe name (for example, breakfast/muffin). Formatting the node pages themselves was impossible, so we had to use views, I'm afraid.
What does the view do exactly?
If it searches for nodes with the argument (say, "Muffin") in their titles, then I think that you should simply change the view URL to something like search_recipe and be done with it.
If it does do something like displaying a single node (so recipe/muffin would be an appropriate unique id), then why are you using Views for this?
Also, you can replace the site's search page with exposed view filters. It's pretty powerful.
This might work?
I've set up a searchable view form - with some filters exposed in the page (and so in the url).
I've disabled site search, don't need it anyway outside this recipe area, and I think I can build a simple block to $GET (or $POST, i always forget) form data to the view.
The view then reads the url and displays appropriately:
index.php?q=recipes%2Fsearch&time=All&keywords=pie
shows recipes containing "pie" in the title.
Just need to build the form now...
edit - yep this worked a treat!
<form id="search-block-form" action="index.php?q=recipes%2Fsearch&time=All" accept-charset="UTF-8" method="get">
<div>
<div class="container-inline right-search">
<div id="edit-search-block-form-1-wrapper" class="form-item">
<label for="edit-search-block-form-1">Quick recipe search: </label>
<input name="q" value="recipes/search" type="hidden" />
<input name="time" value="All" type="hidden" />
<input id="edit-search-block-form-1" class="form-text" title="Enter the recipe terms you wish to search for." maxlength="128" name="keywords" size="15" type="text" />
</div>
<input id="edit-submit" class="form-submit" name="op" type="submit" value="Search" />
</div>
</div>
</form>
This is kind of a workaround, but:
You can try Google Custom Search Engine as default search, and make Google not see node/* URL's using robots.txt.
Just add this below "# Paths (clean URLs)" in the robots.txt file which is on the Drupal root:
Disallow: /node/
(Don't forget that adding this line will stop search engines from crawling all the node/** URLs.)
Also adding views to the sitemap could be helpful for this process.
I've never tried this process, so I can't be sure if it's working or not ;)

Resources