Maybe someone gives me advise how to set default value for input type files in vue (i have file name, but I think I need something more)? I know that v-model is senseless, so I have no idea how to do it, and can't found some solutions.
You cannot set default value to file inputs. You just display file info in separate element and use file input just to upload new files.
E.g.
<div>
{{file.name}}
<!-- Just display the name of the existing file -->
<button #click.prevent="removeFile(file)">Remove</button>
<!-- button to delete existing file -->
</div>
<input type="file" #change="handleUpload">
<!-- Show input just to upload new file and replace the old one -->
Thank you for your answers. Then I try to use v-model there I have error v-model is not allowed here. To be honest there was problem with validation during edit. File input is empty, because I can't preaload data, and validation not allowed to send data to backend.
In the end I decided that when there are edit, file input not need to be required, because object get information about ealier choosen file, and you can change it, but can't remove.
Related
I have a page with multiple textboxes and dropdowns with values that I am trying to validate. The values in them will be dynamic in each run.
The HTML looks something like:
<input readonly="readonly" class="form-control valid" data-val="true" data="ABC" aria-invalid="false" xpath="1">
What I want to do is grab the value of "data" for each textbox. I have used scriptAll before in such a case when I was grabbing text by using innerText. However, that won't work with a regular value such as in the HTML above.
I did try one solution that worked:
driver.value(//input[#data])
However, that just grabs the first textbox value, is there a way I can combine scriptAll with driver.value? OR would I be better off doing some JS here?
Thank you in advance!
Yes, refer the docs for scriptAll(): https://github.com/karatelabs/karate/tree/master/karate-core#scriptall
Use whatever JS works to get an attribute value. Haven't tried, but this should work, you get the idea:
* def list = scriptAll('input', "_.getAttribute('data')")
In _createElement, I want to ask whether data.is is same to the v-bind:is?
https://github.com/vuejs/vue/blob/0baa129d4cad44cf1847b0eaf07e95d4c71ab494/src/core/vdom/create-element.js#L64
Why tag = data.is?
Thanks for every respondent!
As the comment in the code suggests, that line is specifically to handle the case where is is included inside an object v-bind. e.g.:
<component v-bind="{ is: 'button' }">Button</component>
You can see this for yourself by setting a breakpoint in your browser on that line. I'm using Webpack and Chrome and the relevant file appears under webpack:///./node_modules/vue/dist/vue.esm.js in the Sources tab. Quick search for _createElement and click in the margin to set a breakpoint.
In the example above the is value is intended to be used as the tag, whereas component is just a dummy tag that can be discarded.
The syntax above is equivalent to:
<component is="button">Button</component>
or:
<button>Button</button>
However, neither of these two examples will go into the relevant if section. In these other two cases the tag is already resolved correctly prior to this point.
I'm trying to find a way to add a new value using v-select previously not in the list. So that the new value entered will become the selected option.
This is my current code:
<v-select
ref="systemSelect"
v-model="reservation.system"
name="system"
label="Select System"
:disabled="isBusy"
:options="systems"
#input="getSystems"
/>
In UI the component looks like this. Here I use Vuex only to get :options. Currently if I enter a new value and click outside that value disappears since its not found in the list
Expected: Would like to enter a new value and use this value as current in the form and save it. Is there a way to achieve this?
Any help would be appreciated.
Thanks!
If you're using vue select, you can use the attribute taggable and multiple to push your own options:
<v-select taggable multiple />
See this link:
https://vue-select.org/guide/values.html#tagging
How should I add an image field to an odoo survey?
In a survey I need the option to upload an image (or even more than one).
I found this, but I can't figure where or what.
First of all, we have to give the creator of the survey the opportunity to add a binary field to a survey page (used for the image upload)
Create a custom model that inherits from the survey.question model. Add a ('binary','Upload') element in the state field.
Then on addons/survey/views/survey_views.xml find the with the id survey_question_form and change it accordingly (for example when you add a question of type Binary you might want to hide some elements that refer to other types of questions)
After that go to addons/survey/views/survey_templates.xml and add a template:
<template id="binary_field" name="Image">
<input type="image" class="form-control" t-att-name="prefix"/>
</template>
Then, on the same file, find the template with the id = page and add
<t t-if="question.type == 'binary'"><t t-call="survey.binary_field"/></t>
Start testing the whole process by restarting your server with -d your_database_name -u survey and move from there.
More changes might be needed in addition to what I have mentioned.
I have the following code:
<input type="text" dojoType="dijit.form.NumberTextBox" size=8
constraints="{min:0,max:100000,places:0}"
id="orgNumberOfStudents" name="orgNumberOfStudents"
required="true" invalidMessage="Integer between 0 and 100,000"
value="">
Questions:
1) How do I set the width of the box? Do I have to do it in a style tag or a CSS? Is the traditional "input size" tag ignored?
2) The above sample shows the error when I type in a non-numeric value. But if I tab over the field and don't fill in anything, it's still blank. Is there a quick way to enforce the validation when I click the submit button? Do I need a Dijit submitt button? Do I need to write more JavaScript to make this happen? How does the required="true" actually occur?
(One get-around is to set the value to 0, but I'd rather force the user enter a value rather than just defaulting it).
Thanks,
Neal Walters
You should be able to use both CSS and traditional INPUT attributes like "maxLength" on your NumberTextBox by passing them in to the Widget's constructor. maxLength is available on all dijit.form.TextBox subclasses, but is probably less useful here since you have control over things like min/max and the actual number format.
Yes, you can always write your own JS to test "isValid()" on your widget instance before submission, e.g. in an HTML FORM onSubmit handler, or you could use dijit.form.Form which will check validity for you. The widget itself is only responsible for visual representation of its own validity, according to the options chosen.
HTH