How do I read element attribute from $form_state? - drupal-8

I set a data attribute on my autocomplete element using jquery like this
$(event.target).attr('real-value','6');
How do I get this value from my $formstate or $form object in my form submit function? Using dpm $form['elementname'] doesn't even show this atrribute.
I've tried formstate->getValue(). Doesn't work?

Related

In Django what is the method of a `TextField` / `Field` object that returns its content?

In Django when needing to display the content of an object of type django.db.models.fields.TextField in a template, if this object is denoted as textfield, we can display it with the simple {{ textfield }} command.
However, while exploring the code of django.db.models.fields.TextField, I did not find any method returning the content of the TextField. Indeed, while checking django.db.models.fields.TextField and its super class django.db.models.fields.Field I did not find any method that do the job.
Thus, is there such a method returning the content of a TextField or even a Field, else what is the machinery used here to return it ?
That's not how Django fields work. Fields are attributes of the class, not the instance, and are used for loading and saving values from the database; the attribute on the instance is just the plain value.

How to pass parameters to Forms in Sitecore WFFM

Is there a way to pass custom values to a web form in WFFM?
There is a field named "Parameters" under the section "MVC Specific Settings" on "Form" template, setting this field by some values in the content editor and publishing, does not get transfer or populate to the Sitecore.Forms.Mvc.ViewModels.FormViewModel.
For Example:
You can try to get Parameters field value manually by getting rendering datasource item and then parsing Parameters field.

Added a Field to WeBlog Entry template, trying to get the field in Category.ascx.cs

I have followed the steps in the following link Template Settings and created custom templates for Entry, Comment and Category. To the Custom Entry Template, I have added an additional field. I have a requirement to display it in the Categories.ascx. I am able to override the Categories.ascx but I am unable to get the value of the added field using WeBlog's API. Here's the code that I am using. But the issue is that the Class EntryItem doesn't have the additional field that I have added. Is there a way to read this field using WeBlog API?
EntryItem[] blogEntries = ManagerFactory.EntryManagerInstance.GetBlogEntries();
EntryItem inherits from CustomItem I believe, so you can use the InnerItem Property to get access to the actual Item. Your field should then be available like this:
entryItem.InnerITem["YouField"];
You can use a field renderer in the Categories.ascx file to display the value of you field and use data binding to get the item assigned to the field renderer.
<sc:FieldRenderer ID="FieldRenderer1" runat="server" FieldName="YourField" item='<%# entryItem.innerItem %>'/>
In Categories.ascx you can add this code to render the new field on the front-end:
<sc:FieldRenderer FieldName="Your New Field Name" ID="frNewField" runat="server" />
Then in the C# code-behind, add this code to data bind the front-end field renderer to the entry item's underlying Sitecore item:
frNewField.Item = entryItem.InnerItem;

How to get the Value from a input field in QWebView

In Qt I have a QWebView on the screen the site in the web view has an input field,
I want to get the value attribute from the input field and store it in a QString
Basically what I'm asking is how can I store the value of a input field in a QString
From your QWebView get the QWebFrame (e.g ui->webView()->page()->currentFrame()->toHtml();) and then used QwebFrame::findAllElements or QWebFrame::findFirstElement. This will give you a QWebElement and you can use the attribute method to get the value attribute.
You should use evaluateJavaScript("this.value") for dynamic get calues from attributes:
http://www.qtforum.org/article/34091/solved-get-html-dom-dynamic-value-via-qtwebview.html#post109395

How to make fields readonly while updating

I have a form. Once the form is filled I don't want the user to change anything in the form.
But the user can see the values. Meaning all the fields are non editable. I can do this by using instance method but this does not help in foreignkey.
Depends on what you mean "once the form is filled".
If it's an html form post, just render a new html page with simple text and values of the submitted form.
If the post-back was an ajax call, you can change the CSS-styling of the elements for example and disable the submit button or erase the whole and substitute the values that you get back from ajax request.
There is no "editable=False" property on html input elements btw.
you can use readonlyAdmin