How to add custom soup message headers in gjs? - gjs

I can't find any method in Soup.Message that would allow me to add custom headers. I tried adding headers using Message.requset_headers but that field is read only. How can I add custom header to my message?

Message.request_headers is read-only, but its value is a Soup.MessageHeaders instance, which has an append() method you can use to add a custom header.

Related

Drupal 7 form api. Add custom class to element after validation

I looked around and could not find the solution as to how to add a custom class to the form element/elements or the <form> tag for that matter. I have a custom form validation function which does some custom validation. form_set_error does set an error class on the elements but I wanted to add my custom class anywhere within the form tag.
Since the goal is just to customize the display of your field on error, a cleaner way is to create your own theme_form_element() in your theme and use the function form_get_error($element) to add the class you want if any error is returned on a field.
Using this method you can also display the error message next to the field in error, instead of on top of the form.
I found the answer here. Turns out you can use $form_state to make alterations to form after submission. I did
if($haserror) {
$form_state['complete form']['#attributes'] = array('class'=>array('contains_error'));
}

Augment SilverStripe UploadField

I'd like the augment the HTML that gets appended to the Upload field on a file upload and add but I can't seem to find where the where the div.ss-uploadfield-item-info is added.
Specifically I'd like to add a second hidden input after the file ID field.
You need to overwrite the template for the uploadfield, the original is in /framework/templates/UploadField.ss. Using ->setTemplate('YourTemplate') you can even set the template for one single instance of the UploadField.
The hidden field can either be set statically in your own template or using HiddenField.

get a URL as variable and display different div dipending on the URL

Is possible to get a URL as variable and display different div (in the same page) based on the value of the variable (URL). More in the details: if I have a page with a webform/popup(DIV), I want to change the innerhtml of this DIV, based on the response I get from the server.
The easiest approach would be to create those diffs and use css to set the visibility to false as a default behavior.
In the Ajax success-callback you could overwrite, depending on the response, the visibility off one div-container.
The code will obviously depend on what framework you use on the client (jQuery, plain JS, Angular).

How to show wordpress setting api validation error message?

I have created a setting api for my new plugin. It has four <input> field and one <select> option. In that field , user can change value according to their requirement. But it must be valid value. Suppose , one <input> field support only integer value. so when user will fill that <input> field by string or by other things, it will show an error message. Please tell me how can i do that? Can you suggest any tutorial ?
When using add_setting you can pass a sanitize_callback option as part of the array, this can contain the name of a function that is run which can contain your validation.
A similar method exists for JavaScript too, which you could use to validate the fields as well.
You asked for a tutorial too, here is one that outlines the method I've described: http://themeshaper.com/2013/04/29/validation-sanitization-in-customizer/

MvcConrib Grid's Sortable property don't seems to to do any effect

I need a way to generate the header texts in the grid as sortalbe link.
Do I need to use custom renderer to get this behavior?
You need to use GridSortOptions and call the .Sort(YourModel.GridSortOptions) method on the grid and then handle the OrderBy in your controller action.
See this link: http://www.jeremyskinner.co.uk/2010/03/14/mvccontrib-grid-part-6-sorting/
Thanks,
Hal

Resources