Laravel Error on Repopulating: htmlentities() expects parameter 1 to be string, array given in - laravel

I noticed that whenever I am redirecting back to the input form on error using withInput(), there is a very common error that will arise some times. ie
htmlentities() expects parameter 1 to be string, array given (View:[path])
I had realised that this only(usually) occurs whenever i redirect using withInput() but if i dont use it, the error does not occur, and neither are the firlds repopulated. I had however not known why this occurs until I thought avout it yesterday, and this is my view of it.

One of the input fields in my form was a text box array, hence it had the same name like provinces[] in all the fields. Remember that Laravel's Input facade will get it as a variable and on redirecting, it will 'come back' with this variable (which in essence is an array) and load it with the first fields called like the array(provinces). When repopulating, Laravel will (i think) pass the original field value to the e() helper function (htmlentities() in reality), which expects parameter 1 as string but the array is given.
How i solved it: i renamed the fields so that i do not use an array for their names, so that all the fields have a distinct name. That worked for me.
In case my reasoning is flawed, you may correct me with love (and respect for Taylor) ;-)
(Well, as alexrussel had said in htmlentities() expects parameter 1 to be string, array given , this can also occur when in the Form::input() only three parameters are given instead of four.)

I have the same problem but when i searches on this error i found that Laravel Input fields expects parameter 2 to be the value, and parameter 3 to be the array of attributes. So when you pass the attributes where the value should be, htmlspecialchars will flip out. or otherwise just remove the withInput option from the redirecting from controllers method it will work

Related

How to get the matched key from ngx translate?

I have a directive that is sending a whole array of possible "fallback" keys to the Translate pipe's transform method (as the second param, "args"), and ngx somehow settles on the one that actually exists. I know the Translate pipe has a 'lastKey' property, but that turns out to not have the right value if a fallback is chosen.
Is there a way to get what path it actually translated?

Nifi expression language for loops over attributes

Currently I am having around 15 attributes in my flowfile. Out of these 15, i only want a few (all the attributes that have a prefix 'error_' in it. These 'error_*' attributes can have 2 sets of values, eighter- 'valid' or some error code, say- '945'. Now i want to iterate though all the attributes with prefix - 'error_' and if its value is 'valid', do nothing and if its value is having some error code, append the error code to a string separated by ';'. So basically, if I have 5 error_ attributes:
error_field1: '123'
error_field2: 'Valid'
error_field3: '567'
error_field4: 'Valid'
error_field5: '45'
I want my output as - '123;567;45'.
Please help me as i am new to Nifi and i am not sure on how to work with such complex EL.
There are a couple ways to perform this.
${anyMatchingAttribute('error_'):find('\\d+')}
You can use the anyMatchingAttribute() function to evaluate a predicate against multiple attributes, and use the regular expression find() method to check for the presence of digits. This will give you a boolean result, but won't enumerate & join all the values.
${allMatchingAttributes('error_'):join(';'):replaceAll('Valid;', '')}
If you don't need to recall and associate the error codes with the specific field where they were sourced, you can simply concatenate all of the attributes and then use a regular expression to remove the Valid values.

The "getnodevalue" of HTMLUNIT not working on domattr

every time i want to get the Value of my DomAttr i get an TypeError:
My Code:
Wanted = page.getByXPath("//span[contains(.,'Some')]/parent::a/#href");
return this
[DomAttr[name=href value=URLSTRING]]
Now i want to geht the value (=URLSTRING) with Wanted.getNodeName();
but every Time i get the Error
Cannot find function getNodeValue in object [DomAttr[name=href value=
same when i use getValue
please help me
There are some things that make no sense in the code (particularly, because it is not complete). However, I think I can guess what the issue is.
getByXPath is actually returning a List (funny thing you missed the part of the code in which you specify it as a list and replaced it with a Wanted).
Note you should probably also have type warnings in the code too.
Now, you can see that the returned value is in square brackets. That means it is a List (confirming first assumption).
Finally, although you happened to miss that part of the code too, I guess you are directly applying the getValue to the list instead of the DomAttr elements in the list.
How to solve it: If you need more than 1 result iterate over the elements of the list (that Wanted word over there). If you need 1 result then user the getFirstByXPath method.
Were my guesses right?

Type mismatch error while reading lotus notes document in vb6

Am trying to read the lotus notes document using VB6.I can able to read the values of the but suddenly type mismatch error is throwed.When i reintialise the vb6 variable it works but stops after certain point.
ex; address field in lotus notes
lsaddress=ImsField(doc.address)
private function ImsField(pValue)
ImsField=pValue(0)
end function
Like this I am reading the remaining fields but at certain point the runtime error "13" type mismatch error throwed.
I have to manually reintialize by
set doc=view.getdocumentbykey(doclist)
The type mismatch error occurs for a certain field. The issue should be a data type incompatibility. Try to figure out which field causes the error.
Use GetItemValue() instead of short notation for accessing fields and don't use ImsField():
lsaddress=doc.GetItemValue("address")(0)
The type mismatch is occurring because you are encountering a case where pValue is not an array. That will occur when you attempt to reference a NotesItem that does not exist. I.e., doc.MissingItem.
You should not use the shorthand notation doc.itemName. It is convenient, but it leads to sloppy coding. You should use getItemValue as everyone else is suggesting, and also you should check to see if the NotesItem exists. I.e.,
if doc.hasItem("myItem") then
lsaddress=doc.getItemValue("myItem")(0)
end if
Notes and Domino are schema-less. There are no data integrity checks other than what you write yourself. You may think that the item always has to be there, but the truth is that there is nothing that will ever guarantee that, so it is always up to you to write your code so that it doesn't assume anything.
BTW: There are other checks that you might want to perform besides just whether or not the field exists. You might want to check the field's type as well, but to do that requires going one more level up the object chain and using getFirstItem instead of getItemValue, which I'm not going to get into here. And the reason, once again, is that Notes and Domino are schema-less. You might think that a given item must always be a text list, but all it takes is someone writing sloppy code in an one-time fix-it agent and you could end up having a document in which that item is numeric!
Checking your fields is actually a good reason (sometimes) to encapsulate your field access in a function, much like the way you have attempted to do. The reason I added "sometimes" above is that your code's behavior for a missing field isn't necessarily always going to be the same, but for cases where you just want to return a default value when the field doesn't exist you can use something like this:
lsaddress ImsField("address","")
private function ImsField(fieldName,defaultValue)
if doc.hasItem(fieldName) then
lsaddress=doc.getItemValue(fieldName)(0)
else
lsaddress=defaultValue
end if
end function
Type mismatch comes,
When you try to set values from one kind of datatype variable to different datatype of another variable.
Eg:-
dim x as String
Dim z as variant
z= Split("Test:XXX",":")
x=z
The above will through the error what you mentioned.
So check the below code...
lsaddress = ImsField(doc.address)
What is the datatype of lsaddress?
What is the return type of ImsField(doc.address)?
If the above function parameter is a string, then you should pass the parameter like (doc.address(0))

drupal multiple view arguments with PHP code validation for empty arguments

I have a view set up to accept 2 arguments. The url is like this: playlists/video5/%/%/rss.xml
It works fine if I supply the url with 2 arguments like playlists/video5/front/coach/rss.xml.
I have 2 arguments of "Taxonomy: Term"
But I need it to run even if 1 or no arguments are supplied. It looks like you can do this with PHP Code under: Provide default argument options -> Default argument type: -> PHP Code.
I'm using this for the first one:
$arg[0] == 'all';
return 'all';
I'm using this for the second one:
$arg[1] == 'all';
return 'all';
It's working fine in the preview if I enter 1, 2 or no arguments, but in the browser it giving me a "Page not found" error if I use less than 2 arguments in the url.
It woks with these urls:
/playlists/video5/gridiron/all/rss.xml
/playlists/video5/gridiron/football/rss.xml
It does not work with this:
playlists/video5/gridiron/rss.xml
I want it to return all values when no arguments are given, or if only one arg is given, just use the one, etc...
thanks
I would rearrange your URL to look like this: playlists/video5/rss/%/% so that way your arguments always come last. Then in your argument settings set:
Action to take if argument is not present: Display all values
This way when you go to playlists/video5/rss you will get every value. When you go to /playlists/video5/rss/term1 you will get all values that have term1 in them. Then the trick for the second argument is to include the wildcard for first argument like this: /playlists/video5/rss/all/term2. I believe that will include just the values that have the second term.
Alternatively, if these are both taxonomy terms, you may want to consolidate these into a single argument and check the box that says: Allow multiple terms per argument. According to the documentation right below the checkbox, it looks like this should allow you something like playlists/video5/rss/term1+term2 and display all values that have the first or second term.
Views will only collapse the %, not the slashes surrounding it. So while you're trying to use playlists/video5/rss.xml, Views is expecting playlists/video5///rss.xml.
To get what you're looking for, you need to duplicate the View display you're using twice.
For the first duplicate, use playlists/video5/%/rss.xml as the path. In your arguments for this view display, make sure the first argument validates for either gridiron or football.
For the second duplicate, use playlists/video5/rss.xml. There will be no arguments for this view display. If you just want all of the records to show up, you shouldn't have to do anything more. But if you want to supply a default argument other than all the records, you'd override the view display and create a filter instead of an argument.
Another (less ideal) option is to treat gridiron/football as one argument and validate it that way.

Resources